Browse Source

fix:公共看板下面出现两个用户名称一样的目录bug修复

Roc 2 months ago
parent
commit
8f797be7aa
1 changed files with 36 additions and 23 deletions
  1. 36 23
      controllers/bi_dashboard.go

+ 36 - 23
controllers/bi_dashboard.go

@@ -660,36 +660,49 @@ func (this *BIDaShboardController) PublicList() {
 			GroupName: c.BiDashboardClassifyName,
 			Children:  make([]*bi_dashboard.RespPublicGroupListItem, 0),
 		}
-		if _, ok := publicDashboardClassifyIdMap[c.BiDashboardClassifyId]; ok {
-			for _, v := range adminIdList {
-				systemAdmin, ok := systemAdminMap[v]
-				if !ok {
-					continue
-				}
+		_, ok := publicDashboardClassifyIdMap[c.BiDashboardClassifyId]
+		if !ok {
+			continue
+		}
 
-				// 看板 列表信息
-				respGroupNameListItemList, ok := publicDashboardListMap[v]
-				if !ok {
-					respGroupNameListItemList = make([]*bi_dashboard.BiDashboard, 0)
-				}
+		tmpRespGroupIndexMap := make(map[int]int)
+		child := make([]*bi_dashboard.RespPublicGroupListItem, 0)
 
-				// ppt 分组信息
-				tmpRespGroupListItem := &bi_dashboard.RespPublicGroupListItem{
-					GroupId:       int64(systemAdmin.AdminId),
-					GroupName:     systemAdmin.RealName,
-					AdminId:       systemAdmin.AdminId,
-					DashboardList: make([]*bi_dashboard.BiDashboard, 0),
-				}
+		for _, v := range adminIdList {
+			systemAdmin, ok := systemAdminMap[v]
+			if !ok {
+				continue
+			}
+
+			// 看板 列表信息
+			respGroupNameListItemList, ok := publicDashboardListMap[v]
+			if !ok {
+				respGroupNameListItemList = make([]*bi_dashboard.BiDashboard, 0)
+			}
 
-				for _, vv := range respGroupNameListItemList {
-					if vv.BiDashboardClassifyId == c.BiDashboardClassifyId {
-						tmpRespGroupListItem.DashboardList = append(tmpRespGroupListItem.DashboardList, vv)
-						tmpItem.Children = append(tmpItem.Children, tmpRespGroupListItem)
+			for _, vv := range respGroupNameListItemList {
+				if vv.BiDashboardClassifyId == c.BiDashboardClassifyId {
+					tmpIndex, ok := tmpRespGroupIndexMap[systemAdmin.AdminId]
+					if !ok {
+						// 用户的分组信息
+						tmpRespGroupListItem := &bi_dashboard.RespPublicGroupListItem{
+							GroupId:       int64(systemAdmin.AdminId),
+							GroupName:     systemAdmin.RealName,
+							AdminId:       systemAdmin.AdminId,
+							DashboardList: make([]*bi_dashboard.BiDashboard, 0),
+						}
+						tmpIndex = len(child)
+						child = append(child, tmpRespGroupListItem)
+						tmpRespGroupIndexMap[systemAdmin.AdminId] = tmpIndex
 					}
+					tmpRespGroupListItem := child[tmpIndex]
+					child[tmpIndex].DashboardList = append(tmpRespGroupListItem.DashboardList, vv)
+					//tmpItem.Children = append(tmpItem.Children, tmpRespGroupListItem)
 				}
+				tmpItem.Children = child
 			}
-			resp = append(resp, tmpItem)
 		}
+		resp = append(resp, tmpItem)
 	}
 
 	br.Ret = 200