...
|
...
|
@@ -115,32 +115,68 @@ 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) {
|
|
|
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})
|
|
|
// GetHrBp 当前操作人是否拥有HR-BP权限 (1表示有权限)
|
|
|
func GetHrBp(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) {
|
|
|
roleRepository := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
_, roles, err := roleRepository.Find(map[string]interface{}{"type": domain.RoleTypeSystem, "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 len(roles) == 0 {
|
|
|
return -1, nil
|
|
|
}
|
|
|
|
|
|
_, userRoles, err := roleUserRepository.Find(map[string]interface{}{"companyId": companyId, "userId": operatorId})
|
|
|
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
|
|
|
if len(userRoles) == 0 {
|
|
|
return -1, nil
|
|
|
}
|
|
|
|
|
|
hrBp := -1
|
|
|
loopFinish:
|
|
|
for _, userRole := range userRoles {
|
|
|
for _, role := range roles {
|
|
|
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) {
|
|
|
roleRepository := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
_, roles, err := roleRepository.Find(map[string]interface{}{"type": domain.RoleTypeSuperAdmin, "companyId": companyId})
|
|
|
if err != nil {
|
|
|
return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error())
|
|
|
}
|
|
|
if len(roles) == 0 {
|
|
|
return -1, nil
|
|
|
}
|
|
|
|
|
|
_, userRoles, err := roleUserRepository.Find(map[string]interface{}{"companyId": companyId, "userId": operatorId})
|
|
|
if err != nil {
|
|
|
return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error())
|
|
|
}
|
|
|
if len(userRoles) == 0 {
|
|
|
return -1, nil
|
|
|
}
|
|
|
|
|
|
superAdmin := -1
|
|
|
loopFinish:
|
|
|
for _, userRole := range userRoles {
|
|
|
for _, role := range roles {
|
|
|
if userRole.RoleId == role.Id {
|
|
|
superAdmin = domain.RoleTypeSuperAdmin
|
|
|
break loopFinish
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return hrbp, nil
|
|
|
return superAdmin, nil
|
|
|
} |
...
|
...
|
|