|
@@ -27,50 +27,50 @@ func GetMenuAll() ([]protocol.PermissionItem, error) { |
|
@@ -27,50 +27,50 @@ func GetMenuAll() ([]protocol.PermissionItem, error) { |
27
|
return list, nil
|
27
|
return list, nil
|
28
|
}
|
28
|
}
|
29
|
|
29
|
|
30
|
-func FilterMenuByRole(allMenu []protocol.PermissionItem, userid int64, companyid int64) []protocol.PermissionItem {
|
|
|
31
|
- var newMenuList []protocol.PermissionItem
|
|
|
32
|
- ucompany, err := models.GetUserCompanyBy(userid, companyid)
|
|
|
33
|
- if err != nil {
|
|
|
34
|
- log.Error("获取用户数据失败:%s", err)
|
|
|
35
|
- return allMenu
|
|
|
36
|
- }
|
|
|
37
|
- rolegroup, err := models.GetCompanyDefaultRoleGroup(ucompany.CompanyId)
|
|
|
38
|
- if err != nil {
|
|
|
39
|
- log.Error("获取默认的角色组失败:%s", err)
|
|
|
40
|
- return allMenu
|
|
|
41
|
- }
|
|
|
42
|
- rolelist, err := models.GetUserRoleByUser(ucompany.Id)
|
|
|
43
|
- if err != nil {
|
|
|
44
|
- log.Error("获取用户的角色失败:%s", err)
|
|
|
45
|
- return allMenu
|
|
|
46
|
- }
|
|
|
47
|
- var (
|
|
|
48
|
- isIn bool = false
|
|
|
49
|
- )
|
|
|
50
|
- for i := range rolelist {
|
|
|
51
|
- if rolelist[i].Pid == rolegroup.Id {
|
|
|
52
|
- isIn = true
|
|
|
53
|
- }
|
|
|
54
|
- }
|
|
|
55
|
- if isIn {
|
|
|
56
|
- return allMenu
|
|
|
57
|
- }
|
|
|
58
|
- codeMap := map[string]int{
|
|
|
59
|
- M_ENTERPRISE: 1,
|
|
|
60
|
- M_ENTERPRISE_PROFILE: 1,
|
|
|
61
|
- M_ENTERPRISE_ORGANIZATION: 1,
|
|
|
62
|
- M_ENTERPRISE_EMPLOYEE_POST: 1,
|
|
|
63
|
- M_ENTERPRISE_EMPLOYEE_ROLE: 1,
|
|
|
64
|
- M_ENTERPRISE_EMPLOYEE: 1,
|
|
|
65
|
- }
|
|
|
66
|
- for i, v := range allMenu {
|
|
|
67
|
- if _, ok := codeMap[v.Code]; ok {
|
|
|
68
|
- continue
|
|
|
69
|
- }
|
|
|
70
|
- newMenuList = append(newMenuList, allMenu[i])
|
|
|
71
|
- }
|
|
|
72
|
- return newMenuList
|
|
|
73
|
-}
|
30
|
+// func FilterMenuByRole(allMenu []protocol.PermissionItem, userid int64, companyid int64) []protocol.PermissionItem {
|
|
|
31
|
+// var newMenuList []protocol.PermissionItem
|
|
|
32
|
+// ucompany, err := models.GetUserCompanyBy(userid, companyid)
|
|
|
33
|
+// if err != nil {
|
|
|
34
|
+// log.Error("获取用户数据失败:%s", err)
|
|
|
35
|
+// return allMenu
|
|
|
36
|
+// }
|
|
|
37
|
+// rolegroup, err := models.GetCompanyDefaultRoleGroup(ucompany.CompanyId)
|
|
|
38
|
+// if err != nil {
|
|
|
39
|
+// log.Error("获取默认的角色组失败:%s", err)
|
|
|
40
|
+// return allMenu
|
|
|
41
|
+// }
|
|
|
42
|
+// rolelist, err := models.GetUserRoleByUser(ucompany.Id)
|
|
|
43
|
+// if err != nil {
|
|
|
44
|
+// log.Error("获取用户的角色失败:%s", err)
|
|
|
45
|
+// return allMenu
|
|
|
46
|
+// }
|
|
|
47
|
+// var (
|
|
|
48
|
+// isIn bool = false
|
|
|
49
|
+// )
|
|
|
50
|
+// for i := range rolelist {
|
|
|
51
|
+// if rolelist[i].Pid == rolegroup.Id {
|
|
|
52
|
+// isIn = true
|
|
|
53
|
+// }
|
|
|
54
|
+// }
|
|
|
55
|
+// if isIn {
|
|
|
56
|
+// return allMenu
|
|
|
57
|
+// }
|
|
|
58
|
+// codeMap := map[string]int{
|
|
|
59
|
+// M_ENTERPRISE: 1,
|
|
|
60
|
+// M_ENTERPRISE_PROFILE: 1,
|
|
|
61
|
+// M_ENTERPRISE_ORGANIZATION: 1,
|
|
|
62
|
+// M_ENTERPRISE_EMPLOYEE_POST: 1,
|
|
|
63
|
+// M_ENTERPRISE_EMPLOYEE_ROLE: 1,
|
|
|
64
|
+// M_ENTERPRISE_EMPLOYEE: 1,
|
|
|
65
|
+// }
|
|
|
66
|
+// for i, v := range allMenu {
|
|
|
67
|
+// if _, ok := codeMap[v.Code]; ok {
|
|
|
68
|
+// continue
|
|
|
69
|
+// }
|
|
|
70
|
+// newMenuList = append(newMenuList, allMenu[i])
|
|
|
71
|
+// }
|
|
|
72
|
+// return newMenuList
|
|
|
73
|
+// }
|
74
|
|
74
|
|
75
|
func GetRoleHasMenu(roleid int64, companyid int64) (*protocol.ResponseRoleMenus, error) {
|
75
|
func GetRoleHasMenu(roleid int64, companyid int64) (*protocol.ResponseRoleMenus, error) {
|
76
|
var (
|
76
|
var (
|