...
|
...
|
@@ -115,10 +115,8 @@ func (rs *RoleUserService) ListRole(in *command.UserRoleQueryCommand) (interface |
|
|
return tool_funs.SimpleWrapGridMap(total, tempList), nil
|
|
|
}
|
|
|
|
|
|
// GetHRBP 当前操作人是否拥有HRBP权限
|
|
|
// 返回 1 是 表示具有hrbp 权限
|
|
|
|
|
|
func GetHRBP(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) {
|
|
|
// GetHrBp 当前操作人是否拥有HR-BP权限 (1表示有权限)
|
|
|
func GetHrBp(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) {
|
|
|
roleRepo := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
_, roleList, err := roleRepo.Find(map[string]interface{}{"type": domain.RoleTypeSystem, "companyId": companyId})
|
...
|
...
|
@@ -129,18 +127,40 @@ func GetHRBP(transactionContext application.TransactionContext, companyId int, o |
|
|
if err != nil {
|
|
|
return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error())
|
|
|
}
|
|
|
// 拥有HRBP权限
|
|
|
hrbp := -1
|
|
|
for _, v := range userRoleList {
|
|
|
for _, v2 := range roleList {
|
|
|
if v.RoleId == v2.Id {
|
|
|
hrbp = 1
|
|
|
break
|
|
|
hrBp := -1
|
|
|
loopFinish:
|
|
|
for _, userRole := range userRoleList {
|
|
|
for _, role := range roleList {
|
|
|
if userRole.RoleId == role.Id {
|
|
|
hrBp = domain.RoleTypeSystem
|
|
|
break loopFinish
|
|
|
}
|
|
|
}
|
|
|
if hrbp == 1 {
|
|
|
break
|
|
|
}
|
|
|
return hrBp, nil
|
|
|
}
|
|
|
|
|
|
// GetSuperAdmin 当前操作人是否拥有超级管理员权限 (2表示有权限)
|
|
|
func GetSuperAdmin(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) {
|
|
|
roleRepo := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
_, roleList, err := roleRepo.Find(map[string]interface{}{"type": domain.RoleTypeSuperAdmin, "companyId": companyId})
|
|
|
if err != nil {
|
|
|
return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error())
|
|
|
}
|
|
|
_, userRoleList, err := roleUserRepo.Find(map[string]interface{}{"companyId": companyId, "userId": operatorId})
|
|
|
if err != nil {
|
|
|
return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error())
|
|
|
}
|
|
|
superAdmin := -1
|
|
|
loopFinish:
|
|
|
for _, userRole := range userRoleList {
|
|
|
for _, role := range roleList {
|
|
|
if userRole.RoleId == role.Id {
|
|
|
superAdmin = domain.RoleTypeSuperAdmin
|
|
|
break loopFinish
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return hrbp, nil
|
|
|
return superAdmin, nil
|
|
|
} |
...
|
...
|
|