【8.3.3】【role】角色绑定数据范围,校验机构编码是否存在

dev-8.3.3
stylefeng 2025-01-24 23:31:56 +08:00
parent 2ba0ace8b5
commit 1d916adc64
2 changed files with 19 additions and 1 deletions

View File

@ -21,7 +21,12 @@ public enum SysRoleDataScopeExceptionEnum implements AbstractExceptionEnum {
/**
* {}
*/
PARAM_IS_EMPTY(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10002", "存在参数为空,参数名称为:{}");
PARAM_IS_EMPTY(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10002", "存在参数为空,参数名称为:{}"),
/**
*
*/
LEVEL_CODE_IS_ERROR(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10003", "组织机构层级编码不正确");
/**
*

View File

@ -251,6 +251,19 @@ public class SysRoleDataScopeServiceImpl extends ServiceImpl<SysRoleDataScopeMap
if (ObjectUtil.isEmpty(sysRoleDataScopeRequest.getOrgLevelCode())) {
throw new SysException(SysRoleDataScopeExceptionEnum.PARAM_IS_EMPTY, "组织机构层级编码orgLevelCode");
}
// 校验机构编码是否真实存在
boolean levelCodeOk = false;
List<OrganizationLevel> list = orgLevelServiceApi.findList(new OrganizationLevelRequest());
for (OrganizationLevel organizationLevel : list) {
if (organizationLevel.getLevelCode().equals(sysRoleDataScopeRequest.getOrgLevelCode())) {
levelCodeOk = true;
break;
}
}
if (!levelCodeOk) {
throw new SysException(SysRoleDataScopeExceptionEnum.LEVEL_CODE_IS_ERROR);
}
}
// 如果是新增的是指定机构,则判断机构参数