diff --git a/kernel-s-system/system-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/role/enums/exception/SysRoleDataScopeExceptionEnum.java b/kernel-s-system/system-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/role/enums/exception/SysRoleDataScopeExceptionEnum.java index abd9deeb0..0e85d80ed 100644 --- a/kernel-s-system/system-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/role/enums/exception/SysRoleDataScopeExceptionEnum.java +++ b/kernel-s-system/system-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/role/enums/exception/SysRoleDataScopeExceptionEnum.java @@ -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", "组织机构层级编码不正确"); /** * 错误编码 diff --git a/kernel-s-system/system-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/role/service/impl/SysRoleDataScopeServiceImpl.java b/kernel-s-system/system-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/role/service/impl/SysRoleDataScopeServiceImpl.java index 8aaee3899..95a71b4c5 100644 --- a/kernel-s-system/system-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/role/service/impl/SysRoleDataScopeServiceImpl.java +++ b/kernel-s-system/system-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/role/service/impl/SysRoleDataScopeServiceImpl.java @@ -251,6 +251,19 @@ public class SysRoleDataScopeServiceImpl extends ServiceImpl 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); + } } // 如果是新增的是指定机构,则判断机构参数