mirror of https://gitee.com/stylefeng/roses
【8.3.3】【sys】【org】机构层级编码不能重复
parent
a18827a820
commit
1d6560d6c7
|
@ -16,7 +16,22 @@ public enum OrganizationLevelExceptionEnum implements AbstractExceptionEnum {
|
|||
/**
|
||||
* 查询结果不存在
|
||||
*/
|
||||
ORGANIZATION_LEVEL_NOT_EXISTED(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10001", "查询结果不存在");
|
||||
ORGANIZATION_LEVEL_NOT_EXISTED(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10001", "查询结果不存在"),
|
||||
|
||||
/**
|
||||
* 层级不能重复
|
||||
*/
|
||||
NUMBER_CANT_REPEAT(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10002", "层级不能重复"),
|
||||
|
||||
/**
|
||||
* 组织机构层级编码不能重复
|
||||
*/
|
||||
CODE_CANT_REPEAT(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10003", "层级编码不能重复"),
|
||||
|
||||
/**
|
||||
* 组织机构层级名称不能重复
|
||||
*/
|
||||
NAME_CANT_REPEAT(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10003", "层级名称不能重复");
|
||||
|
||||
/**
|
||||
* 错误编码
|
||||
|
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|||
import cn.stylefeng.roses.kernel.sys.api.exception.SysException;
|
||||
import cn.stylefeng.roses.kernel.sys.api.exception.enums.OrgExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.org.entity.OrganizationLevel;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.org.enums.OrganizationLevelExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.org.mapper.OrganizationLevelMapper;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.org.pojo.request.OrganizationLevelRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.org.service.OrganizationLevelService;
|
||||
|
@ -60,6 +61,22 @@ public class OrganizationLevelServiceImpl extends ServiceImpl<OrganizationLevelM
|
|||
temp.setLevelColor(organizationLevel.getLevelColor());
|
||||
newList.add(temp);
|
||||
}
|
||||
|
||||
// 层级的编码、number、名称不能重复
|
||||
for (int i = 0; i < newList.size(); i++) {
|
||||
for (int j = i + 1; j < newList.size(); j++) {
|
||||
if (newList.get(i).getLevelCode().equals(newList.get(j).getLevelCode())) {
|
||||
throw new SysException(OrganizationLevelExceptionEnum.CODE_CANT_REPEAT);
|
||||
}
|
||||
if (newList.get(i).getLevelNumber().equals(newList.get(j).getLevelNumber())) {
|
||||
throw new SysException(OrganizationLevelExceptionEnum.NUMBER_CANT_REPEAT);
|
||||
}
|
||||
if (newList.get(i).getLevelName().equals(newList.get(j).getLevelName())) {
|
||||
throw new SysException(OrganizationLevelExceptionEnum.NAME_CANT_REPEAT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.saveBatch(newList);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue