Commit 97b31bf2 authored by cq990612's avatar cq990612

优化代码结构

parent 28e69919
......@@ -283,14 +283,13 @@ public class WorkUserServiceImpl implements WorkUserService {
workCentreService.updateById(centre);
}
}
}else {
int roleCountByRoleId = UserRoleLevelUtils.getRoleCountByRoleId(4,userId);
if (roleCountByRoleId == 0) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.ATLEASTONEADMINISTRATORISREQUIRED);
}
}
workUserRoleMapper.insertBatch(userId, roleIds);
// 判断管理员是否至少有一个
int roleCountByRoleId = UserRoleLevelUtils.getRoleCountByRoleId(4);
if (roleCountByRoleId == 0) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.ATLEASTONEADMINISTRATORISREQUIRED);
}
return true;
}
......
......@@ -200,20 +200,15 @@ public class UserRoleLevelUtils {
return ranks;
}
public static int getRoleCountByRoleId(Integer roleId,Integer userId) {
public static int getRoleCountByRoleId(Integer roleId) {
if (null == roleId) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
List<WorkUser> users = utils.workUserRoleMapper.getUserRoleDeptDtoByRoleId(roleId);
int i = 0;
if (!CollectionUtils.isEmpty(users)) {
for (WorkUser user : users) {
if (!user.getId().equals(userId)) {
i++;
}
}
return users.size();
}
return i;
return 0;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment