合并分支 'test' 到 'master'
Test 查看合并请求 !8
正在显示
11 个修改的文件
包含
151 行增加
和
101 行删除
@@ -26,6 +26,8 @@ type CreateMenuCommand struct { | @@ -26,6 +26,8 @@ type CreateMenuCommand struct { | ||
26 | IsPublish int `json:"isPublish" valid:"Required"` | 26 | IsPublish int `json:"isPublish" valid:"Required"` |
27 | // 启用状态(启用:1 禁用:2),默认启用 | 27 | // 启用状态(启用:1 禁用:2),默认启用 |
28 | EnableStatus int `json:"enableStatus" ` | 28 | EnableStatus int `json:"enableStatus" ` |
29 | + // 外链接(需要菜单跳转的时候使用) | ||
30 | + Link string `json:"link"` | ||
29 | } | 31 | } |
30 | 32 | ||
31 | func (createMenuCommand *CreateMenuCommand) Valid(validation *validation.Validation) { | 33 | func (createMenuCommand *CreateMenuCommand) Valid(validation *validation.Validation) { |
@@ -29,6 +29,8 @@ type UpdateMenuCommand struct { | @@ -29,6 +29,8 @@ type UpdateMenuCommand struct { | ||
29 | IsPublish int `json:"isPublish,omitempty"` | 29 | IsPublish int `json:"isPublish,omitempty"` |
30 | // 启用状态(启用:1 禁用:2),默认启用 | 30 | // 启用状态(启用:1 禁用:2),默认启用 |
31 | EnableStatus int `json:"enableStatus"` | 31 | EnableStatus int `json:"enableStatus"` |
32 | + // 外链接(需要菜单跳转的时候使用) | ||
33 | + Link string `json:"link"` | ||
32 | } | 34 | } |
33 | 35 | ||
34 | func (updateMenuCommand *UpdateMenuCommand) Valid(validation *validation.Validation) { | 36 | func (updateMenuCommand *UpdateMenuCommand) Valid(validation *validation.Validation) { |
@@ -34,6 +34,8 @@ type Menu struct { | @@ -34,6 +34,8 @@ type Menu struct { | ||
34 | //IsPublish int `json:"isPublish,omitempty"` | 34 | //IsPublish int `json:"isPublish,omitempty"` |
35 | // 启用状态(启用:1 禁用:2),默认启用 | 35 | // 启用状态(启用:1 禁用:2),默认启用 |
36 | EnableStatus int `json:"enableStatus,omitempty"` | 36 | EnableStatus int `json:"enableStatus,omitempty"` |
37 | + // 外链接(需要菜单跳转的时候使用) | ||
38 | + Link string `json:"link"` | ||
37 | } | 39 | } |
38 | 40 | ||
39 | func (dto *UserAccessMenuDto) LoadDto(menus []*domain.Menu) error { | 41 | func (dto *UserAccessMenuDto) LoadDto(menus []*domain.Menu) error { |
@@ -49,6 +51,7 @@ func (dto *UserAccessMenuDto) LoadDto(menus []*domain.Menu) error { | @@ -49,6 +51,7 @@ func (dto *UserAccessMenuDto) LoadDto(menus []*domain.Menu) error { | ||
49 | Sort: v.Sort, | 51 | Sort: v.Sort, |
50 | EnableStatus: v.EnableStatus, | 52 | EnableStatus: v.EnableStatus, |
51 | ParentPath: v.ParentPath, | 53 | ParentPath: v.ParentPath, |
54 | + Link: v.Link, | ||
52 | }) | 55 | }) |
53 | } | 56 | } |
54 | 57 |
@@ -66,7 +66,7 @@ func (userService *UserService) BatchAdd2(batchAddCommand *command.BatchAdd2Comm | @@ -66,7 +66,7 @@ func (userService *UserService) BatchAdd2(batchAddCommand *command.BatchAdd2Comm | ||
66 | "transactionContext": transactionContext, | 66 | "transactionContext": transactionContext, |
67 | }) | 67 | }) |
68 | var failRows []*domain.BatchAddUserItem | 68 | var failRows []*domain.BatchAddUserItem |
69 | - if failRows, err = batchAddUserService.BatchAddUser2(batchAddCommand.OperateInfo, batchAddCommand.Users, batchAddCommand.Password); err != nil { | 69 | + if failRows, err = batchAddUserService.BatchAddUser(batchAddCommand.OperateInfo, batchAddCommand.Users, batchAddCommand.Password); err != nil { |
70 | return batchAddCommand.Users, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 70 | return batchAddCommand.Users, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
71 | } | 71 | } |
72 | if len(failRows) != 0 { | 72 | if len(failRows) != 0 { |
@@ -68,9 +68,10 @@ type Menu struct { | @@ -68,9 +68,10 @@ type Menu struct { | ||
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 | // 父级菜单名称 | 75 | // 父级菜单名称 |
75 | ParentMenuName string `json:"parentMenuName,omitempty"` | 76 | ParentMenuName string `json:"parentMenuName,omitempty"` |
76 | } | 77 | } |
@@ -3,6 +3,8 @@ package domain | @@ -3,6 +3,8 @@ package domain | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/constant" | 5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/constant" |
6 | + "strconv" | ||
7 | + "strings" | ||
6 | "time" | 8 | "time" |
7 | ) | 9 | ) |
8 | 10 | ||
@@ -44,7 +46,7 @@ type Org struct { | @@ -44,7 +46,7 @@ type Org struct { | ||
44 | OrgStatus int `json:"orgStatus,omitempty"` | 46 | OrgStatus int `json:"orgStatus,omitempty"` |
45 | // 父级ID | 47 | // 父级ID |
46 | ParentId int64 `json:"parentId,omitempty"` | 48 | ParentId int64 `json:"parentId,omitempty"` |
47 | - // 父级节点路径("0,11,12,") | 49 | + // 父级节点路径("11,12") 注意:parent_id为0时 parentPath "",公司级别的组织没有父级组织 |
48 | ParentPath string `json:"parentPath,omitempty"` | 50 | ParentPath string `json:"parentPath,omitempty"` |
49 | 51 | ||
50 | // 企业id | 52 | // 企业id |
@@ -197,6 +199,23 @@ func (org *Org) ID() string { | @@ -197,6 +199,23 @@ func (org *Org) ID() string { | ||
197 | return org.GetFullPath() | 199 | return org.GetFullPath() |
198 | } | 200 | } |
199 | 201 | ||
202 | +func (org *Org) IsChild(pid int64) bool { | ||
203 | + paths := strings.Split(org.ParentPath, PathSegment) | ||
204 | + pidStr := strconv.FormatInt(pid, 10) | ||
205 | + if org.OrgId == pid { | ||
206 | + return true | ||
207 | + } | ||
208 | + if org.ParentId == pid { | ||
209 | + return true | ||
210 | + } | ||
211 | + for _, v := range paths { | ||
212 | + if strings.EqualFold(pidStr, v) { | ||
213 | + return true | ||
214 | + } | ||
215 | + } | ||
216 | + return false | ||
217 | +} | ||
218 | + | ||
200 | /***** 2.缓存模块 *****/ | 219 | /***** 2.缓存模块 *****/ |
201 | 220 | ||
202 | func (m *Org) CacheKeyFunc() string { | 221 | func (m *Org) CacheKeyFunc() string { |
@@ -4,6 +4,5 @@ import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" | @@ -4,6 +4,5 @@ import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" | ||
4 | 4 | ||
5 | // PgBatchAddUserService 批量添加用户服务 | 5 | // PgBatchAddUserService 批量添加用户服务 |
6 | type PgBatchAddUserService interface { | 6 | type PgBatchAddUserService interface { |
7 | - BatchAddUser(optUser *domain.OperateInfo, users []*domain.User, password string) error | ||
8 | - BatchAddUser2(optUser *domain.OperateInfo, users []*domain.BatchAddUserItem, password string) ([]*domain.BatchAddUserItem, error) | 7 | + BatchAddUser(optUser *domain.OperateInfo, users []*domain.BatchAddUserItem, password string) ([]*domain.BatchAddUserItem, error) |
9 | } | 8 | } |
@@ -18,71 +18,71 @@ type PgBatchAddUserService struct { | @@ -18,71 +18,71 @@ type PgBatchAddUserService struct { | ||
18 | // optUser 操作用户 | 18 | // optUser 操作用户 |
19 | // users 待添加用户列表数据 | 19 | // users 待添加用户列表数据 |
20 | // password 密码 | 20 | // password 密码 |
21 | -func (ptr *PgBatchAddUserService) BatchAddUser(optUser *domain.OperateInfo, users []*domain.User, password string) error { | ||
22 | - var ( | ||
23 | - err error | ||
24 | - ) | ||
25 | - orgRepository, err := repository.NewOrgRepository(ptr.transactionContext) | ||
26 | - if err != nil { | ||
27 | - return err | ||
28 | - } | ||
29 | - _, orgs, err := orgRepository.Find(map[string]interface{}{"companyId": optUser.CompanyId}) | ||
30 | - if err != nil { | ||
31 | - return err | ||
32 | - } | ||
33 | - var mapOrg = make(map[int64]*domain.Org) | ||
34 | - for i := range orgs { | ||
35 | - mapOrg[orgs[i].OrgId] = orgs[i] | ||
36 | - } | ||
37 | - | ||
38 | - createUserService, _ := NewPgCreateUserService(ptr.transactionContext) | ||
39 | - for i := range users { | ||
40 | - user := users[i] | ||
41 | - if err = ptr.preCheck(user); err != nil { | ||
42 | - return err | ||
43 | - } | ||
44 | - newUser := &domain.User{ | ||
45 | - CompanyId: user.CompanyId, | ||
46 | - UserType: user.UserType, | ||
47 | - UserCode: user.UserCode, | ||
48 | - OrganizationId: user.OrganizationId, | ||
49 | - DepartmentId: user.DepartmentId, | ||
50 | - UserOrg: []*domain.Org{}, | ||
51 | - UserRole: []*domain.Role{}, | ||
52 | - FavoriteMenus: []string{}, | ||
53 | - CooperationInfo: user.CooperationInfo, | ||
54 | - UserInfo: user.UserInfo, | ||
55 | - EnableStatus: int(domain.UserStatusEnable), | ||
56 | - Ext: &domain.Ext{ | ||
57 | - Phone: user.UserInfo.Phone, | ||
58 | - UserName: user.UserInfo.UserName, | ||
59 | - }, | ||
60 | - CreatedAt: time.Now(), | ||
61 | - UpdatedAt: time.Now(), | ||
62 | - } | ||
63 | - if user.OrganizationId > 0 { | ||
64 | - if v, ok := mapOrg[user.OrganizationId]; ok && v.CompanyId == user.CompanyId { | ||
65 | - newUser.Ext.OrgName = v.OrgName | ||
66 | - } else { | ||
67 | - return fmt.Errorf("导入的组织机构不存在") | ||
68 | - } | ||
69 | - } | ||
70 | - if user.DepartmentId > 0 { | ||
71 | - if v, ok := mapOrg[user.DepartmentId]; ok && v.CompanyId == user.CompanyId { | ||
72 | - newUser.Ext.DepName = v.OrgName | ||
73 | - } else { | ||
74 | - return fmt.Errorf("导入的所属部门不存在") | ||
75 | - } | ||
76 | - } | ||
77 | - | ||
78 | - if newUser, err = createUserService.CreateUser(nil, newUser, password); err != nil { | ||
79 | - return err | ||
80 | - } | ||
81 | - } | ||
82 | - return nil | ||
83 | -} | 21 | +//func (ptr *PgBatchAddUserService) BatchAddUser(optUser *domain.OperateInfo, users []*domain.User, password string) error { |
22 | +// var ( | ||
23 | +// err error | ||
24 | +// ) | ||
25 | +// orgRepository, err := repository.NewOrgRepository(ptr.transactionContext) | ||
26 | +// if err != nil { | ||
27 | +// return err | ||
28 | +// } | ||
29 | +// _, orgs, err := orgRepository.Find(map[string]interface{}{"companyId": optUser.CompanyId}) | ||
30 | +// if err != nil { | ||
31 | +// return err | ||
32 | +// } | ||
33 | +// var mapOrg = make(map[int64]*domain.Org) | ||
34 | +// for i := range orgs { | ||
35 | +// mapOrg[orgs[i].OrgId] = orgs[i] | ||
36 | +// } | ||
37 | +// | ||
38 | +// createUserService, _ := NewPgCreateUserService(ptr.transactionContext) | ||
39 | +// for i := range users { | ||
40 | +// user := users[i] | ||
41 | +// if err = ptr.preCheck(user); err != nil { | ||
42 | +// return err | ||
43 | +// } | ||
44 | +// newUser := &domain.User{ | ||
45 | +// CompanyId: user.CompanyId, | ||
46 | +// UserType: user.UserType, | ||
47 | +// UserCode: user.UserCode, | ||
48 | +// OrganizationId: user.OrganizationId, | ||
49 | +// DepartmentId: user.DepartmentId, | ||
50 | +// UserOrg: []*domain.Org{}, | ||
51 | +// UserRole: []*domain.Role{}, | ||
52 | +// FavoriteMenus: []string{}, | ||
53 | +// CooperationInfo: user.CooperationInfo, | ||
54 | +// UserInfo: user.UserInfo, | ||
55 | +// EnableStatus: int(domain.UserStatusEnable), | ||
56 | +// Ext: &domain.Ext{ | ||
57 | +// Phone: user.UserInfo.Phone, | ||
58 | +// UserName: user.UserInfo.UserName, | ||
59 | +// }, | ||
60 | +// CreatedAt: time.Now(), | ||
61 | +// UpdatedAt: time.Now(), | ||
62 | +// } | ||
63 | +// if user.OrganizationId > 0 { | ||
64 | +// if v, ok := mapOrg[user.OrganizationId]; ok && v.CompanyId == user.CompanyId { | ||
65 | +// newUser.Ext.OrgName = v.OrgName | ||
66 | +// } else { | ||
67 | +// return fmt.Errorf("导入的组织机构不存在") | ||
68 | +// } | ||
69 | +// } | ||
70 | +// if user.DepartmentId > 0 { | ||
71 | +// if v, ok := mapOrg[user.DepartmentId]; ok && v.CompanyId == user.CompanyId { | ||
72 | +// newUser.Ext.DepName = v.OrgName | ||
73 | +// } else { | ||
74 | +// return fmt.Errorf("导入的所属部门不存在") | ||
75 | +// } | ||
76 | +// } | ||
77 | +// | ||
78 | +// if newUser, err = createUserService.CreateUser(nil, newUser, password); err != nil { | ||
79 | +// return err | ||
80 | +// } | ||
81 | +// } | ||
82 | +// return nil | ||
83 | +//} | ||
84 | 84 | ||
85 | -func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, users []*domain.BatchAddUserItem, password string) ([]*domain.BatchAddUserItem, error) { | 85 | +func (ptr *PgBatchAddUserService) BatchAddUser(optUser *domain.OperateInfo, users []*domain.BatchAddUserItem, password string) ([]*domain.BatchAddUserItem, error) { |
86 | var ( | 86 | var ( |
87 | err error | 87 | err error |
88 | ) | 88 | ) |
@@ -99,6 +99,10 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use | @@ -99,6 +99,10 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use | ||
99 | for i := range orgs { | 99 | for i := range orgs { |
100 | mapOrg[orgs[i].OrgCode] = orgs[i] | 100 | mapOrg[orgs[i].OrgCode] = orgs[i] |
101 | } | 101 | } |
102 | + optUserOrg, err := orgRepository.FindOne(map[string]interface{}{"orgId": optUser.OrgId}) | ||
103 | + if err != nil { | ||
104 | + return failRows, err | ||
105 | + } | ||
102 | 106 | ||
103 | createUserService, _ := NewPgCreateUserService(ptr.transactionContext) | 107 | createUserService, _ := NewPgCreateUserService(ptr.transactionContext) |
104 | for i := range users { | 108 | for i := range users { |
@@ -108,23 +112,31 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use | @@ -108,23 +112,31 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use | ||
108 | failRows = append(failRows, user) | 112 | failRows = append(failRows, user) |
109 | continue | 113 | continue |
110 | } | 114 | } |
111 | - var org, dep *domain.Org | 115 | + var org = optUserOrg |
116 | + var dep *domain.Org | ||
112 | var ok bool | 117 | var ok bool |
113 | - if org, ok = mapOrg[user.Org]; !ok { | ||
114 | - user.FailReason = "导入的组织机构不存在:" + user.Org | ||
115 | - failRows = append(failRows, user) | ||
116 | - continue | ||
117 | - } | 118 | + // 使用导入用户的组织作为默认组织 |
119 | + //if org, ok = mapOrg[user.Org]; !ok { | ||
120 | + // user.FailReason = "导入的组织机构不存在:" + user.Org | ||
121 | + // failRows = append(failRows, user) | ||
122 | + // continue | ||
123 | + //} | ||
118 | if dep, ok = mapOrg[user.Department]; !ok && user.UserType != domain.UserTypeCooperation { | 124 | if dep, ok = mapOrg[user.Department]; !ok && user.UserType != domain.UserTypeCooperation { |
119 | user.FailReason = "导入的所属部门不存在:" + user.Department | 125 | user.FailReason = "导入的所属部门不存在:" + user.Department |
120 | failRows = append(failRows, user) | 126 | failRows = append(failRows, user) |
121 | continue | 127 | continue |
122 | } | 128 | } |
129 | + //TODO:子部门判断 | ||
130 | + //if dep != nil && !dep.IsChild(optUser.OrgId) { | ||
131 | + // user.FailReason = fmt.Sprintf("导入的所属部门不是当前登录组织(%v)的子部门:%v", optUserOrg.OrgName, user.Department) | ||
132 | + // failRows = append(failRows, user) | ||
133 | + // continue | ||
134 | + //} | ||
123 | newUser := &domain.User{ | 135 | newUser := &domain.User{ |
124 | CompanyId: user.CompanyId, | 136 | CompanyId: user.CompanyId, |
125 | UserType: user.UserType, | 137 | UserType: user.UserType, |
126 | UserCode: user.UserCode, | 138 | UserCode: user.UserCode, |
127 | - OrganizationId: org.OrgId, | 139 | + OrganizationId: optUser.OrgId, |
128 | UserOrg: []*domain.Org{}, | 140 | UserOrg: []*domain.Org{}, |
129 | UserRole: []*domain.Role{}, | 141 | UserRole: []*domain.Role{}, |
130 | FavoriteMenus: []string{}, | 142 | FavoriteMenus: []string{}, |
@@ -172,24 +184,24 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use | @@ -172,24 +184,24 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use | ||
172 | return failRows, nil | 184 | return failRows, nil |
173 | } | 185 | } |
174 | 186 | ||
175 | -func (ptr *PgBatchAddUserService) preCheck(user *domain.User) error { | ||
176 | - if len(user.UserCode) == 0 { | ||
177 | - return fmt.Errorf("导入的用户编码为空值") | ||
178 | - } | ||
179 | - if len(user.UserInfo.UserName) == 0 { | ||
180 | - return fmt.Errorf("导入的用户姓名为空值") | ||
181 | - } | ||
182 | - if len(user.UserInfo.Phone) == 0 || len(user.UserInfo.Phone) != 11 { | ||
183 | - return fmt.Errorf("导入的手机号不是有效手机号") | ||
184 | - } | ||
185 | - if user.OrganizationId == 0 { | ||
186 | - return fmt.Errorf("导入的组织机构不存在") | ||
187 | - } | ||
188 | - if user.DepartmentId == 0 && user.UserType == domain.UserTypeEmployee { | ||
189 | - return fmt.Errorf("导入的所属部门不存在") | ||
190 | - } | ||
191 | - return nil | ||
192 | -} | 187 | +//func (ptr *PgBatchAddUserService) preCheck(user *domain.User) error { |
188 | +// if len(user.UserCode) == 0 { | ||
189 | +// return fmt.Errorf("导入的用户编码为空值") | ||
190 | +// } | ||
191 | +// if len(user.UserInfo.UserName) == 0 { | ||
192 | +// return fmt.Errorf("导入的用户姓名为空值") | ||
193 | +// } | ||
194 | +// if len(user.UserInfo.Phone) == 0 || len(user.UserInfo.Phone) != 11 { | ||
195 | +// return fmt.Errorf("导入的手机号不是有效手机号") | ||
196 | +// } | ||
197 | +// if user.OrganizationId == 0 { | ||
198 | +// return fmt.Errorf("导入的组织机构不存在") | ||
199 | +// } | ||
200 | +// if user.DepartmentId == 0 && user.UserType == domain.UserTypeEmployee { | ||
201 | +// return fmt.Errorf("导入的所属部门不存在") | ||
202 | +// } | ||
203 | +// return nil | ||
204 | +//} | ||
193 | 205 | ||
194 | func (ptr *PgBatchAddUserService) preCheck2(user *domain.BatchAddUserItem) error { | 206 | func (ptr *PgBatchAddUserService) preCheck2(user *domain.BatchAddUserItem) error { |
195 | if len(user.UserCode) == 0 { | 207 | if len(user.UserCode) == 0 { |
@@ -22,6 +22,7 @@ type PgRoleAccessMenusService struct { | @@ -22,6 +22,7 @@ type PgRoleAccessMenusService struct { | ||
22 | func (ptr *PgRoleAccessMenusService) AccessMenus(options *domain.OperateInfo, roleIds []int64, option domain.AccessMenusOptions) ([]*domain.Menu, error) { | 22 | func (ptr *PgRoleAccessMenusService) AccessMenus(options *domain.OperateInfo, roleIds []int64, option domain.AccessMenusOptions) ([]*domain.Menu, error) { |
23 | var err error | 23 | var err error |
24 | var menus []*domain.Menu | 24 | var menus []*domain.Menu |
25 | + var hasAdminRole bool = false | ||
25 | menuIdSet := hashset.New() | 26 | menuIdSet := hashset.New() |
26 | if len(roleIds) == 0 { | 27 | if len(roleIds) == 0 { |
27 | return menus, nil | 28 | return menus, nil |
@@ -34,6 +35,9 @@ func (ptr *PgRoleAccessMenusService) AccessMenus(options *domain.OperateInfo, ro | @@ -34,6 +35,9 @@ func (ptr *PgRoleAccessMenusService) AccessMenus(options *domain.OperateInfo, ro | ||
34 | 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 { |
35 | continue | 36 | continue |
36 | } | 37 | } |
38 | + if role.RoleType&domain.RoleTypeAdmin > 0 { | ||
39 | + hasAdminRole = true | ||
40 | + } | ||
37 | // 只要当前登录组织的有权限菜单 | 41 | // 只要当前登录组织的有权限菜单 |
38 | if option.OrgId > 0 && option.OrgId != role.OrgId { | 42 | if option.OrgId > 0 && option.OrgId != role.OrgId { |
39 | continue | 43 | continue |
@@ -66,7 +70,7 @@ func (ptr *PgRoleAccessMenusService) AccessMenus(options *domain.OperateInfo, ro | @@ -66,7 +70,7 @@ func (ptr *PgRoleAccessMenusService) AccessMenus(options *domain.OperateInfo, ro | ||
66 | if err != nil { | 70 | if err != nil { |
67 | return nil, err | 71 | return nil, err |
68 | } | 72 | } |
69 | - _, alias, err := customizeMenuRepository.Find(map[string]interface{}{"companyId": option.CompanyId}) | 73 | + _, menuAlias, err := customizeMenuRepository.Find(map[string]interface{}{"companyId": option.CompanyId}) |
70 | if err != nil { | 74 | if err != nil { |
71 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 75 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
72 | } | 76 | } |
@@ -75,17 +79,22 @@ func (ptr *PgRoleAccessMenusService) AccessMenus(options *domain.OperateInfo, ro | @@ -75,17 +79,22 @@ func (ptr *PgRoleAccessMenusService) AccessMenus(options *domain.OperateInfo, ro | ||
75 | var mapMenus = make(map[int64]*domain.Menu) | 79 | var mapMenus = make(map[int64]*domain.Menu) |
76 | for i := range menus { | 80 | for i := range menus { |
77 | menus[i].EnableStatus = domain.MenuStatusDisable | 81 | menus[i].EnableStatus = domain.MenuStatusDisable |
82 | + if menus[i].IsPublish == domain.MenuPublic && hasAdminRole { | ||
83 | + menus[i].EnableStatus = domain.MenuStatusEnable //管理员角色,返回所有权限 | ||
84 | + } | ||
78 | mapMenus[menus[i].MenuId] = menus[i] | 85 | mapMenus[menus[i].MenuId] = menus[i] |
79 | } | 86 | } |
80 | - for i := range alias { | ||
81 | - if v, ok := mapMenus[alias[i].MenuId]; ok { | ||
82 | - v.MenuName = alias[i].MenuAlias // 设置别名 | ||
83 | - v.Sort = alias[i].Sort | 87 | + // 4.1.设置别名 |
88 | + for i := range menuAlias { | ||
89 | + if v, ok := mapMenus[menuAlias[i].MenuId]; ok { | ||
90 | + v.MenuName = menuAlias[i].MenuAlias | ||
91 | + v.Sort = menuAlias[i].Sort | ||
84 | } | 92 | } |
85 | } | 93 | } |
94 | + // 4.2.设置菜单权限状态 | ||
86 | values := menuIdSet.Values() | 95 | values := menuIdSet.Values() |
87 | for i := range values { | 96 | for i := range values { |
88 | - menuId := (values[i]).(int64) // 设置菜单权限状态 | 97 | + menuId := (values[i]).(int64) |
89 | if v, ok := mapMenus[menuId]; ok { | 98 | if v, ok := mapMenus[menuId]; ok { |
90 | v.EnableStatus = domain.MenuStatusEnable | 99 | v.EnableStatus = domain.MenuStatusEnable |
91 | } | 100 | } |
@@ -28,6 +28,8 @@ type Menu struct { | @@ -28,6 +28,8 @@ type Menu struct { | ||
28 | IsPublish int `comment:"菜单是否公开状态,[2:隐藏],[1:显示],默认显示"` | 28 | IsPublish int `comment:"菜单是否公开状态,[2:隐藏],[1:显示],默认显示"` |
29 | // 启用状态(启用:1 禁用:2),默认启用 | 29 | // 启用状态(启用:1 禁用:2),默认启用 |
30 | EnableStatus int `comment:"启用状态(启用:1 禁用:2),默认启用"` | 30 | EnableStatus int `comment:"启用状态(启用:1 禁用:2),默认启用"` |
31 | + // 外链接(需要菜单跳转的时候使用) | ||
32 | + Link string `json:"link"` | ||
31 | // 删除时间 | 33 | // 删除时间 |
32 | //DeletedAt time.Time `comment:"删除时间"` | 34 | //DeletedAt time.Time `comment:"删除时间"` |
33 | } | 35 | } |
@@ -21,5 +21,6 @@ func TransformToMenuDomainModelFromPgModels(menuModel *models.Menu) (*domain.Men | @@ -21,5 +21,6 @@ func TransformToMenuDomainModelFromPgModels(menuModel *models.Menu) (*domain.Men | ||
21 | ParentPath: menuModel.ParentPath, | 21 | ParentPath: menuModel.ParentPath, |
22 | IsPublish: menuModel.IsPublish, | 22 | IsPublish: menuModel.IsPublish, |
23 | EnableStatus: menuModel.EnableStatus, | 23 | EnableStatus: menuModel.EnableStatus, |
24 | + Link: menuModel.Link, | ||
24 | }, nil | 25 | }, nil |
25 | } | 26 | } |
-
请 注册 或 登录 后发表评论