作者 yangfu

fix: 管理员角色权限修改

@@ -66,9 +66,9 @@ type Menu struct { @@ -66,9 +66,9 @@ type Menu struct {
66 Category string `json:"category,omitempty"` 66 Category string `json:"category,omitempty"`
67 // 路径节点路径("0,11,12,") 67 // 路径节点路径("0,11,12,")
68 ParentPath string `json:"parentPath,omitempty"` 68 ParentPath string `json:"parentPath,omitempty"`
69 - // 菜单是否公开状态,[1:显示],[2:隐藏],默认显示 (移除不使用) 69 + // 菜单是否公开状态,[1:显示],[2:隐藏],默认显示
70 IsPublish int `json:"isPublish,omitempty"` 70 IsPublish int `json:"isPublish,omitempty"`
71 - // 启用状态(启用:1 禁用:2),默认启用 71 + // 启用状态(启用:1 禁用:2),默认启用 (移除不使用,现在只有is_publish状态)
72 EnableStatus int `json:"enableStatus,omitempty"` 72 EnableStatus int `json:"enableStatus,omitempty"`
73 // 外链接(需要菜单跳转的时候使用) 73 // 外链接(需要菜单跳转的时候使用)
74 Link string `json:"link"` 74 Link string `json:"link"`
@@ -46,7 +46,7 @@ type Org struct { @@ -46,7 +46,7 @@ type Org struct {
46 OrgStatus int `json:"orgStatus,omitempty"` 46 OrgStatus int `json:"orgStatus,omitempty"`
47 // 父级ID 47 // 父级ID
48 ParentId int64 `json:"parentId,omitempty"` 48 ParentId int64 `json:"parentId,omitempty"`
49 - // 父级节点路径("0,11,12,") 49 + // 父级节点路径("11,12") 注意:parent_id为0时 parentPath "",公司级别的组织没有父级组织
50 ParentPath string `json:"parentPath,omitempty"` 50 ParentPath string `json:"parentPath,omitempty"`
51 51
52 // 企业id 52 // 企业id
@@ -202,6 +202,12 @@ func (org *Org) ID() string { @@ -202,6 +202,12 @@ func (org *Org) ID() string {
202 func (org *Org) IsChild(pid int64) bool { 202 func (org *Org) IsChild(pid int64) bool {
203 paths := strings.Split(org.ParentPath, PathSegment) 203 paths := strings.Split(org.ParentPath, PathSegment)
204 pidStr := strconv.FormatInt(pid, 10) 204 pidStr := strconv.FormatInt(pid, 10)
  205 + if org.OrgId == pid {
  206 + return true
  207 + }
  208 + if org.ParentId == pid {
  209 + return true
  210 + }
205 for _, v := range paths { 211 for _, v := range paths {
206 if strings.EqualFold(pidStr, v) { 212 if strings.EqualFold(pidStr, v) {
207 return true 213 return true
@@ -112,7 +112,8 @@ func (ptr *PgBatchAddUserService) BatchAddUser(optUser *domain.OperateInfo, user @@ -112,7 +112,8 @@ func (ptr *PgBatchAddUserService) BatchAddUser(optUser *domain.OperateInfo, user
112 failRows = append(failRows, user) 112 failRows = append(failRows, user)
113 continue 113 continue
114 } 114 }
115 - var org, dep *domain.Org 115 + var org = optUserOrg
  116 + var dep *domain.Org
116 var ok bool 117 var ok bool
117 // 使用导入用户的组织作为默认组织 118 // 使用导入用户的组织作为默认组织
118 //if org, ok = mapOrg[user.Org]; !ok { 119 //if org, ok = mapOrg[user.Org]; !ok {
@@ -35,6 +35,9 @@ func (ptr *PgRoleAccessMenusService) AccessMenus(options *domain.OperateInfo, ro @@ -35,6 +35,9 @@ func (ptr *PgRoleAccessMenusService) AccessMenus(options *domain.OperateInfo, ro
35 if role, _ = roleRepository.FindOne(map[string]interface{}{"roleId": roleIds[i]}); role == nil { 35 if role, _ = roleRepository.FindOne(map[string]interface{}{"roleId": roleIds[i]}); role == nil {
36 continue 36 continue
37 } 37 }
  38 + if role.RoleType&domain.RoleTypeAdmin > 0 {
  39 + hasAdminRole = true
  40 + }
38 // 只要当前登录组织的有权限菜单 41 // 只要当前登录组织的有权限菜单
39 if option.OrgId > 0 && option.OrgId != role.OrgId { 42 if option.OrgId > 0 && option.OrgId != role.OrgId {
40 continue 43 continue
@@ -42,9 +45,6 @@ func (ptr *PgRoleAccessMenusService) AccessMenus(options *domain.OperateInfo, ro @@ -42,9 +45,6 @@ func (ptr *PgRoleAccessMenusService) AccessMenus(options *domain.OperateInfo, ro
42 for i := 0; i < len(role.AccessMenus); i++ { 45 for i := 0; i < len(role.AccessMenus); i++ {
43 menuIdSet.Add(role.AccessMenus[i]) 46 menuIdSet.Add(role.AccessMenus[i])
44 } 47 }
45 - if role.RoleType&domain.RoleTypeAdmin > 0 {  
46 - hasAdminRole = true  
47 - }  
48 } 48 }
49 49
50 // 2.获取所有公开的菜单 50 // 2.获取所有公开的菜单
@@ -78,11 +78,9 @@ func (ptr *PgRoleAccessMenusService) AccessMenus(options *domain.OperateInfo, ro @@ -78,11 +78,9 @@ func (ptr *PgRoleAccessMenusService) AccessMenus(options *domain.OperateInfo, ro
78 // 4. 设置别名、返回有效的菜单列表 78 // 4. 设置别名、返回有效的菜单列表
79 var mapMenus = make(map[int64]*domain.Menu) 79 var mapMenus = make(map[int64]*domain.Menu)
80 for i := range menus { 80 for i := range menus {
81 - if menus[i].EnableStatus == domain.MenuStatusEnable {  
82 - menus[i].EnableStatus = domain.MenuStatusDisable  
83 - if hasAdminRole {  
84 - menus[i].EnableStatus = domain.MenuStatusEnable //管理员角色,返回所有权限  
85 - } 81 + menus[i].EnableStatus = domain.MenuStatusDisable
  82 + if menus[i].IsPublish == domain.MenuPublic && hasAdminRole {
  83 + menus[i].EnableStatus = domain.MenuStatusEnable //管理员角色,返回所有权限
86 } 84 }
87 mapMenus[menus[i].MenuId] = menus[i] 85 mapMenus[menus[i].MenuId] = menus[i]
88 } 86 }