Commit efd6b198 authored by cq990612's avatar cq990612

优化代码结构

parent 25e74661
......@@ -19,6 +19,6 @@ public class WorkRole {
@ApiModelProperty(name = "name",value = "角色名")
private String name;
@ApiModelProperty(name = "onlyOne",value = "是否只能有一个:0:多个,1:一个")
@ApiModelProperty(name = "onlyOne",value = "大于0且相同就重复")
private Integer onlyOne;
}
......@@ -215,7 +215,7 @@ public class WorkUserServiceImpl implements WorkUserService {
if (CollectionUtils.isEmpty(roleIds)) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.CHOOSEATLEASTONEROLE);
}
if (UserRoleLevelUtils.levelIsRepeat(roleIds)) {
if (UserRoleLevelUtils.roleIsRepeat(roleIds)) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.DUPLICATEROLEPERMISSIONS);
}
if (null == userId) {
......
......@@ -163,17 +163,19 @@ public class UserRoleLevelUtils {
/**
* 判断权限是否重复
*/
public static Boolean levelIsRepeat(List<Integer> roles) {
public static Boolean roleIsRepeat(List<Integer> roles) {
if (CollectionUtils.isEmpty(roles)) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.ROLE_CANNOTBE_EMPTY);
}
List<Integer> getlevelIds = getlevelIds(roles);
Set<Integer> hashSet = new HashSet<>();
if (!CollectionUtils.isEmpty(getlevelIds)) {
for (Integer id : getlevelIds) {
if (!hashSet.add(id)){
//有重复值
return true;
List<WorkRole> workRoles = utils.workRoleMapper.selectBatchIds(roles);
if (CollectionUtils.isEmpty(workRoles)) {
Set<Integer> hashSet = new HashSet<>();
for (WorkRole workRole : workRoles) {
if (workRole.getOnlyOne()>0) {
if (!hashSet.add(workRole.getOnlyOne())){
//有重复值
return true;
}
}
}
}
......
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