...
|
...
|
@@ -27,50 +27,50 @@ func GetMenuAll() ([]protocol.PermissionItem, error) { |
|
|
return list, nil
|
|
|
}
|
|
|
|
|
|
func FilterMenuByRole(allMenu []protocol.PermissionItem, userid int64, companyid int64) []protocol.PermissionItem {
|
|
|
var newMenuList []protocol.PermissionItem
|
|
|
ucompany, err := models.GetUserCompanyBy(userid, companyid)
|
|
|
if err != nil {
|
|
|
log.Error("获取用户数据失败:%s", err)
|
|
|
return allMenu
|
|
|
}
|
|
|
rolegroup, err := models.GetCompanyDefaultRoleGroup(ucompany.CompanyId)
|
|
|
if err != nil {
|
|
|
log.Error("获取默认的角色组失败:%s", err)
|
|
|
return allMenu
|
|
|
}
|
|
|
rolelist, err := models.GetUserRoleByUser(ucompany.Id)
|
|
|
if err != nil {
|
|
|
log.Error("获取用户的角色失败:%s", err)
|
|
|
return allMenu
|
|
|
}
|
|
|
var (
|
|
|
isIn bool = false
|
|
|
)
|
|
|
for i := range rolelist {
|
|
|
if rolelist[i].Pid == rolegroup.Id {
|
|
|
isIn = true
|
|
|
}
|
|
|
}
|
|
|
if isIn {
|
|
|
return allMenu
|
|
|
}
|
|
|
codeMap := map[string]int{
|
|
|
M_ENTERPRISE: 1,
|
|
|
M_ENTERPRISE_PROFILE: 1,
|
|
|
M_ENTERPRISE_ORGANIZATION: 1,
|
|
|
M_ENTERPRISE_EMPLOYEE_POST: 1,
|
|
|
M_ENTERPRISE_EMPLOYEE_ROLE: 1,
|
|
|
M_ENTERPRISE_EMPLOYEE: 1,
|
|
|
}
|
|
|
for i, v := range allMenu {
|
|
|
if _, ok := codeMap[v.Code]; ok {
|
|
|
continue
|
|
|
}
|
|
|
newMenuList = append(newMenuList, allMenu[i])
|
|
|
}
|
|
|
return newMenuList
|
|
|
}
|
|
|
// func FilterMenuByRole(allMenu []protocol.PermissionItem, userid int64, companyid int64) []protocol.PermissionItem {
|
|
|
// var newMenuList []protocol.PermissionItem
|
|
|
// ucompany, err := models.GetUserCompanyBy(userid, companyid)
|
|
|
// if err != nil {
|
|
|
// log.Error("获取用户数据失败:%s", err)
|
|
|
// return allMenu
|
|
|
// }
|
|
|
// rolegroup, err := models.GetCompanyDefaultRoleGroup(ucompany.CompanyId)
|
|
|
// if err != nil {
|
|
|
// log.Error("获取默认的角色组失败:%s", err)
|
|
|
// return allMenu
|
|
|
// }
|
|
|
// rolelist, err := models.GetUserRoleByUser(ucompany.Id)
|
|
|
// if err != nil {
|
|
|
// log.Error("获取用户的角色失败:%s", err)
|
|
|
// return allMenu
|
|
|
// }
|
|
|
// var (
|
|
|
// isIn bool = false
|
|
|
// )
|
|
|
// for i := range rolelist {
|
|
|
// if rolelist[i].Pid == rolegroup.Id {
|
|
|
// isIn = true
|
|
|
// }
|
|
|
// }
|
|
|
// if isIn {
|
|
|
// return allMenu
|
|
|
// }
|
|
|
// codeMap := map[string]int{
|
|
|
// M_ENTERPRISE: 1,
|
|
|
// M_ENTERPRISE_PROFILE: 1,
|
|
|
// M_ENTERPRISE_ORGANIZATION: 1,
|
|
|
// M_ENTERPRISE_EMPLOYEE_POST: 1,
|
|
|
// M_ENTERPRISE_EMPLOYEE_ROLE: 1,
|
|
|
// M_ENTERPRISE_EMPLOYEE: 1,
|
|
|
// }
|
|
|
// for i, v := range allMenu {
|
|
|
// if _, ok := codeMap[v.Code]; ok {
|
|
|
// continue
|
|
|
// }
|
|
|
// newMenuList = append(newMenuList, allMenu[i])
|
|
|
// }
|
|
|
// return newMenuList
|
|
|
// }
|
|
|
|
|
|
func GetRoleHasMenu(roleid int64, companyid int64) (*protocol.ResponseRoleMenus, error) {
|
|
|
var (
|
...
|
...
|
|