diff --git a/kernel-a-rule/src/main/java/cn/stylefeng/roses/kernel/rule/enums/permission/DataScopeTypeEnum.java b/kernel-a-rule/src/main/java/cn/stylefeng/roses/kernel/rule/enums/permission/DataScopeTypeEnum.java index 9d045a8aa..beedf1f51 100644 --- a/kernel-a-rule/src/main/java/cn/stylefeng/roses/kernel/rule/enums/permission/DataScopeTypeEnum.java +++ b/kernel-a-rule/src/main/java/cn/stylefeng/roses/kernel/rule/enums/permission/DataScopeTypeEnum.java @@ -24,6 +24,9 @@ */ package cn.stylefeng.roses.kernel.rule.enums.permission; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.util.ObjectUtil; +import cn.stylefeng.roses.kernel.rule.base.ReadableEnum; import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException; import cn.stylefeng.roses.kernel.rule.exception.enums.DataScopeExceptionEnum; import lombok.Getter; @@ -35,7 +38,7 @@ import lombok.Getter; * @since 2020/11/5 15:22 */ @Getter -public enum DataScopeTypeEnum { +public enum DataScopeTypeEnum implements ReadableEnum { /** * 仅本人数据 @@ -105,4 +108,26 @@ public enum DataScopeTypeEnum { throw new ServiceException(DataScopeExceptionEnum.DATA_SCOPE_ERROR); } + @Override + public Object getKey() { + return code; + } + + @Override + public Object getName() { + return message; + } + + @Override + public DataScopeTypeEnum parseToEnum(String originValue) { + if (ObjectUtil.isEmpty(originValue)) { + return null; + } + for (DataScopeTypeEnum value : DataScopeTypeEnum.values()) { + if (value.code.equals(Convert.toInt(originValue))) { + return value; + } + } + return null; + } } diff --git a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/sys/api/OrgLevelServiceApi.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/sys/api/OrgLevelServiceApi.java new file mode 100644 index 000000000..34c7adfb5 --- /dev/null +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/sys/api/OrgLevelServiceApi.java @@ -0,0 +1,26 @@ +package cn.stylefeng.roses.kernel.sys.api; + +import cn.stylefeng.roses.kernel.sys.api.entity.OrganizationLevel; +import cn.stylefeng.roses.kernel.sys.api.pojo.org.OrganizationLevelRequest; + +import java.util.List; + +/** + * 单独编写用户和组织机构关系的Api + * + * @author fengshuonan + * @since 2023/6/18 23:14 + */ +public interface OrgLevelServiceApi { + + /** + * 获取机构层级列表 + * + * @param organizationLevelRequest 请求参数 + * @return List 返回结果 + * @author fengshuonan + * @since 2025/01/22 09:44 + */ + List findList(OrganizationLevelRequest organizationLevelRequest); + +} diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/entity/OrganizationLevel.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/sys/api/entity/OrganizationLevel.java similarity index 96% rename from kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/entity/OrganizationLevel.java rename to kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/sys/api/entity/OrganizationLevel.java index c6bb7c4c3..f6e020f05 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/entity/OrganizationLevel.java +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/sys/api/entity/OrganizationLevel.java @@ -1,4 +1,4 @@ -package cn.stylefeng.roses.kernel.sys.modular.org.entity; +package cn.stylefeng.roses.kernel.sys.api.entity; import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity; import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription; diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/pojo/request/OrganizationLevelRequest.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/sys/api/pojo/org/OrganizationLevelRequest.java similarity index 82% rename from kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/pojo/request/OrganizationLevelRequest.java rename to kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/sys/api/pojo/org/OrganizationLevelRequest.java index c4d15b650..641a70128 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/pojo/request/OrganizationLevelRequest.java +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/sys/api/pojo/org/OrganizationLevelRequest.java @@ -1,8 +1,8 @@ -package cn.stylefeng.roses.kernel.sys.modular.org.pojo.request; +package cn.stylefeng.roses.kernel.sys.api.pojo.org; import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription; import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest; -import cn.stylefeng.roses.kernel.sys.modular.org.entity.OrganizationLevel; +import cn.stylefeng.roses.kernel.sys.api.entity.OrganizationLevel; import jakarta.validation.constraints.NotEmpty; import lombok.Data; import lombok.EqualsAndHashCode; diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/controller/OrganizationLevelController.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/controller/OrganizationLevelController.java index db040f37c..7eab401bf 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/controller/OrganizationLevelController.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/controller/OrganizationLevelController.java @@ -5,8 +5,8 @@ import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData; import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource; import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource; import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource; -import cn.stylefeng.roses.kernel.sys.modular.org.entity.OrganizationLevel; -import cn.stylefeng.roses.kernel.sys.modular.org.pojo.request.OrganizationLevelRequest; +import cn.stylefeng.roses.kernel.sys.api.entity.OrganizationLevel; +import cn.stylefeng.roses.kernel.sys.api.pojo.org.OrganizationLevelRequest; import cn.stylefeng.roses.kernel.sys.modular.org.service.OrganizationLevelService; import jakarta.annotation.Resource; import org.springframework.validation.annotation.Validated; diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/entity/HrOrganization.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/entity/HrOrganization.java index f36980e21..4680745bc 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/entity/HrOrganization.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/entity/HrOrganization.java @@ -3,6 +3,7 @@ package cn.stylefeng.roses.kernel.sys.modular.org.entity; import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseExpandFieldEntity; import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription; import cn.stylefeng.roses.kernel.rule.tree.factory.base.AbstractTreeNode; +import cn.stylefeng.roses.kernel.sys.api.entity.OrganizationLevel; import com.baomidou.mybatisplus.annotation.*; import lombok.Data; import lombok.EqualsAndHashCode; diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/mapper/OrganizationLevelMapper.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/mapper/OrganizationLevelMapper.java index 4198a8a78..e3a0d10bf 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/mapper/OrganizationLevelMapper.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/mapper/OrganizationLevelMapper.java @@ -1,7 +1,7 @@ package cn.stylefeng.roses.kernel.sys.modular.org.mapper; -import cn.stylefeng.roses.kernel.sys.modular.org.entity.OrganizationLevel; -import cn.stylefeng.roses.kernel.sys.modular.org.pojo.request.OrganizationLevelRequest; +import cn.stylefeng.roses.kernel.sys.api.entity.OrganizationLevel; +import cn.stylefeng.roses.kernel.sys.api.pojo.org.OrganizationLevelRequest; import cn.stylefeng.roses.kernel.sys.modular.org.pojo.response.OrganizationLevelVo; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/mapper/mapping/OrganizationLevelMapper.xml b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/mapper/mapping/OrganizationLevelMapper.xml index cce4e1fe6..562a36297 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/mapper/mapping/OrganizationLevelMapper.xml +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/mapper/mapping/OrganizationLevelMapper.xml @@ -3,7 +3,7 @@ - + diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/pojo/response/OrganizationLevelVo.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/pojo/response/OrganizationLevelVo.java index afb0ef508..eac9c80a9 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/pojo/response/OrganizationLevelVo.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/pojo/response/OrganizationLevelVo.java @@ -1,6 +1,6 @@ package cn.stylefeng.roses.kernel.sys.modular.org.pojo.response; -import cn.stylefeng.roses.kernel.sys.modular.org.entity.OrganizationLevel; +import cn.stylefeng.roses.kernel.sys.api.entity.OrganizationLevel; import lombok.Data; import lombok.EqualsAndHashCode; diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/service/OrganizationLevelService.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/service/OrganizationLevelService.java index 970257554..151dbe005 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/service/OrganizationLevelService.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/service/OrganizationLevelService.java @@ -1,28 +1,17 @@ package cn.stylefeng.roses.kernel.sys.modular.org.service; -import cn.stylefeng.roses.kernel.sys.modular.org.entity.OrganizationLevel; -import cn.stylefeng.roses.kernel.sys.modular.org.pojo.request.OrganizationLevelRequest; +import cn.stylefeng.roses.kernel.sys.api.OrgLevelServiceApi; +import cn.stylefeng.roses.kernel.sys.api.entity.OrganizationLevel; +import cn.stylefeng.roses.kernel.sys.api.pojo.org.OrganizationLevelRequest; import com.baomidou.mybatisplus.extension.service.IService; -import java.util.List; - /** * 组织机构层级服务类 * * @author fengshuonan * @since 2025/01/22 09:44 */ -public interface OrganizationLevelService extends IService { - - /** - * 获取机构层级列表 - * - * @param organizationLevelRequest 请求参数 - * @return List 返回结果 - * @author fengshuonan - * @since 2025/01/22 09:44 - */ - List findList(OrganizationLevelRequest organizationLevelRequest); +public interface OrganizationLevelService extends IService, OrgLevelServiceApi { /** * 新增组织机构层级 diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/service/impl/HrOrganizationServiceImpl.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/service/impl/HrOrganizationServiceImpl.java index 272e3af36..d006536cb 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/service/impl/HrOrganizationServiceImpl.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/service/impl/HrOrganizationServiceImpl.java @@ -26,19 +26,19 @@ import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict; import cn.stylefeng.roses.kernel.rule.tree.factory.DefaultTreeBuildFactory; import cn.stylefeng.roses.kernel.sys.api.callback.RemoveOrgCallbackApi; import cn.stylefeng.roses.kernel.sys.api.constants.SysConstants; +import cn.stylefeng.roses.kernel.sys.api.entity.OrganizationLevel; import cn.stylefeng.roses.kernel.sys.api.enums.org.DetectModeEnum; import cn.stylefeng.roses.kernel.sys.api.enums.org.OrgTypeEnum; import cn.stylefeng.roses.kernel.sys.api.exception.enums.OrgExceptionEnum; import cn.stylefeng.roses.kernel.sys.api.pojo.org.CompanyDeptDTO; import cn.stylefeng.roses.kernel.sys.api.pojo.org.HrOrganizationDTO; +import cn.stylefeng.roses.kernel.sys.api.pojo.org.OrganizationLevelRequest; import cn.stylefeng.roses.kernel.sys.modular.org.constants.OrgConstants; import cn.stylefeng.roses.kernel.sys.modular.org.entity.HrOrganization; -import cn.stylefeng.roses.kernel.sys.modular.org.entity.OrganizationLevel; import cn.stylefeng.roses.kernel.sys.modular.org.factory.OrganizationFactory; import cn.stylefeng.roses.kernel.sys.modular.org.mapper.HrOrganizationMapper; import cn.stylefeng.roses.kernel.sys.modular.org.pojo.request.CommonOrgTreeRequest; import cn.stylefeng.roses.kernel.sys.modular.org.pojo.request.HrOrganizationRequest; -import cn.stylefeng.roses.kernel.sys.modular.org.pojo.request.OrganizationLevelRequest; import cn.stylefeng.roses.kernel.sys.modular.org.pojo.response.CommonOrgTreeResponse; import cn.stylefeng.roses.kernel.sys.modular.org.pojo.response.HomeCompanyInfo; import cn.stylefeng.roses.kernel.sys.modular.org.service.HrOrganizationService; diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/service/impl/OrganizationLevelServiceImpl.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/service/impl/OrganizationLevelServiceImpl.java index 93961739a..6e01da123 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/service/impl/OrganizationLevelServiceImpl.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/service/impl/OrganizationLevelServiceImpl.java @@ -1,12 +1,12 @@ package cn.stylefeng.roses.kernel.sys.modular.org.service.impl; import cn.hutool.core.util.ObjectUtil; +import cn.stylefeng.roses.kernel.sys.api.entity.OrganizationLevel; 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.api.pojo.org.OrganizationLevelRequest; 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; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; diff --git a/kernel-s-system/system-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/role/entity/SysRoleDataScope.java b/kernel-s-system/system-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/role/entity/SysRoleDataScope.java index 6790552a4..349a5103f 100644 --- a/kernel-s-system/system-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/role/entity/SysRoleDataScope.java +++ b/kernel-s-system/system-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/role/entity/SysRoleDataScope.java @@ -2,6 +2,11 @@ package cn.stylefeng.roses.kernel.sys.modular.role.entity; import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity; import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription; +import cn.stylefeng.roses.kernel.rule.annotation.EnumFieldFormat; +import cn.stylefeng.roses.kernel.rule.annotation.SimpleFieldFormat; +import cn.stylefeng.roses.kernel.rule.enums.permission.DataScopeTypeEnum; +import cn.stylefeng.roses.kernel.sys.api.entity.OrganizationLevel; +import cn.stylefeng.roses.kernel.sys.api.format.OrgNameFormatProcess; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; @@ -44,7 +49,8 @@ public class SysRoleDataScope extends BaseEntity { */ @TableField("data_scope_type") @ChineseDescription("数据范围类型:10-仅本人数据,20-本部门数据,30-本部门及以下数据,31-本公司及以下数据,32-指定机构层级及以下,40-指定机构集合数据,41-指定机构及以下,50-全部数据") - private Integer data_scope_type; + @EnumFieldFormat(processEnum = DataScopeTypeEnum.class) + private Integer dataScopeType; /** * 层级的编码,用在类型为32-指定层级及以下,情况时使用 @@ -58,6 +64,7 @@ public class SysRoleDataScope extends BaseEntity { */ @TableField(value = "define_org_list", typeHandler = JacksonTypeHandler.class) @ChineseDescription("指定机构集合列表,用在类型为40-指定机构集合数据,情况时使用") + @SimpleFieldFormat(processClass = OrgNameFormatProcess.class) private List defineOrgList; /** @@ -65,8 +72,18 @@ public class SysRoleDataScope extends BaseEntity { */ @TableField("define_org_id") @ChineseDescription("指定机构的id,用在类型为41-指定机构及以下,情况时使用") + @SimpleFieldFormat(processClass = OrgNameFormatProcess.class) private Long defineOrgId; + //-------------------------------非实体字段------------------------------- + + /** + * 层级的详情 + */ + @TableField(exist = false) + @ChineseDescription("层级的详情") + private OrganizationLevel organizationLevel; + //-------------------------------移除掉的字段------------------------------- /** 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 74157214e..8c5422b34 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 @@ -10,7 +10,10 @@ import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult; import cn.stylefeng.roses.kernel.log.api.util.BusinessLogUtil; import cn.stylefeng.roses.kernel.rule.enums.permission.DataScopeTypeEnum; import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException; +import cn.stylefeng.roses.kernel.sys.api.OrgLevelServiceApi; import cn.stylefeng.roses.kernel.sys.api.callback.RemoveRoleCallbackApi; +import cn.stylefeng.roses.kernel.sys.api.entity.OrganizationLevel; +import cn.stylefeng.roses.kernel.sys.api.pojo.org.OrganizationLevelRequest; import cn.stylefeng.roses.kernel.sys.api.pojo.role.response.RoleBindDataScopeResponse; import cn.stylefeng.roses.kernel.sys.modular.role.entity.SysRoleDataScope; import cn.stylefeng.roses.kernel.sys.modular.role.enums.exception.SysRoleDataScopeExceptionEnum; @@ -39,12 +42,14 @@ import java.util.stream.Collectors; * @date 2023/06/10 21:29 */ @Service -public class SysRoleDataScopeServiceImpl extends ServiceImpl implements SysRoleDataScopeService, - RemoveRoleCallbackApi { +public class SysRoleDataScopeServiceImpl extends ServiceImpl implements SysRoleDataScopeService, RemoveRoleCallbackApi { @Resource private SysRoleService sysRoleService; + @Resource + private OrgLevelServiceApi orgLevelServiceApi; + @Override public void add(SysRoleDataScopeRequest sysRoleDataScopeRequest) { SysRoleDataScope sysRoleDataScope = new SysRoleDataScope(); @@ -74,6 +79,27 @@ public class SysRoleDataScopeServiceImpl extends ServiceImpl findPage(SysRoleDataScopeRequest sysRoleDataScopeRequest) { LambdaQueryWrapper wrapper = createWrapper(sysRoleDataScopeRequest); Page sysRolePage = this.page(PageFactory.defaultPage(), wrapper); + + List records = sysRolePage.getRecords(); + if (ObjectUtil.isEmpty(records)) { + return PageResultFactory.createPageResult(sysRolePage); + } + + // 组织机构层级编码,转化为层级的名称 + boolean haveOrgLevelType = false; + for (SysRoleDataScope record : records) { + if (DataScopeTypeEnum.DEFINE_ORG_LEVEL_WITH_CHILD.getCode().equals(record.getDataScopeType())) { + haveOrgLevelType = true; + break; + } + } + if (haveOrgLevelType) { + List list = orgLevelServiceApi.findList(new OrganizationLevelRequest()); + for (SysRoleDataScope record : records) { + record.setOrganizationLevel(list.stream().filter(item -> item.getLevelCode().equals(record.getOrgLevelCode())).findFirst().orElse(null)); + } + } + return PageResultFactory.createPageResult(sysRolePage); } @@ -190,8 +216,10 @@ public class SysRoleDataScopeServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper<>(); // 根据角色id进行查询 - Long roleId = sysRoleDataScopeRequest.getRoleId(); - queryWrapper.eq(ObjectUtil.isNotNull(roleId), SysRoleDataScope::getRoleId, roleId); + queryWrapper.eq(SysRoleDataScope::getRoleId, sysRoleDataScopeRequest.getRoleId()); + + // 按类型排序 + queryWrapper.orderByAsc(SysRoleDataScope::getDataScopeType); return queryWrapper; }