Browse Source

fix:用户权限显示

zqbao 9 months ago
parent
commit
3db2eb812c
1 changed files with 7 additions and 3 deletions
  1. 7 3
      controllers/user.go

+ 7 - 3
controllers/user.go

@@ -508,6 +508,10 @@ func (this *UserAuthController) PermissionList() {
 		br.ErrMsg = "查询用户权限失败,系统异常,Err:" + err.Error()
 		return
 	}
+	userPermissionMap := make(map[int]struct{})
+	for _, v := range permissionIds {
+		userPermissionMap[v] = struct{}{}
+	}
 	// 查询公有权限
 	var publicView []*models.ChartPermissionTreeView
 	publicResp, err := services.GetPublicChartPermissionList()
@@ -545,9 +549,9 @@ func (this *UserAuthController) PermissionList() {
 				Sort:              v.Sort,
 				Child:             make([]*models.ChartPermissionTreeView, 0),
 			}
-			for _, vv := range permissionIds {
-				if v.ChartPermissionId == vv {
-					curPermissionView.Child = append(curPermissionView.Child, v)
+			for _, vv := range v.Child {
+				if _, ok := userPermissionMap[vv.ChartPermissionId]; ok {
+					curPermissionView.Child = append(curPermissionView.Child, vv)
 					IsAdd = true
 				}
 			}