diff --git a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/DataScopeApi.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/DataScopeApi.java index 0c4bd0876..5a1dd59f8 100644 --- a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/DataScopeApi.java +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/DataScopeApi.java @@ -1,6 +1,6 @@ package cn.stylefeng.roses.kernel.system; -import cn.stylefeng.roses.kernel.system.pojo.organization.DataScopeResponse; +import cn.stylefeng.roses.kernel.system.pojo.organization.DataScopeDTO; import cn.stylefeng.roses.kernel.system.pojo.role.response.SysRoleResponse; import java.util.List; @@ -26,6 +26,6 @@ public interface DataScopeApi { * @author majianguo * @date 2020/11/5 上午11:44 */ - DataScopeResponse getDataScope(Long userId, List sysRoles); + DataScopeDTO getDataScope(Long userId, List sysRoles); } diff --git a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/OrganizationServiceApi.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/OrganizationServiceApi.java index edb9f098c..3f6e5a338 100644 --- a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/OrganizationServiceApi.java +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/OrganizationServiceApi.java @@ -1,6 +1,6 @@ package cn.stylefeng.roses.kernel.system; -import cn.stylefeng.roses.kernel.system.pojo.organization.HrOrganizationResponse; +import cn.stylefeng.roses.kernel.system.pojo.organization.HrOrganizationDTO; import java.util.List; @@ -19,5 +19,6 @@ public interface OrganizationServiceApi { * @author liuhanqing * @date 2021/1/15 10:41 */ - List orgList(); + List orgList(); + } diff --git a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/exception/enums/DataScopeExceptionEnum.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/exception/enums/organization/DataScopeExceptionEnum.java similarity index 95% rename from kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/exception/enums/DataScopeExceptionEnum.java rename to kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/exception/enums/organization/DataScopeExceptionEnum.java index e2b46934e..9ae50123b 100644 --- a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/exception/enums/DataScopeExceptionEnum.java +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/exception/enums/organization/DataScopeExceptionEnum.java @@ -1,4 +1,4 @@ -package cn.stylefeng.roses.kernel.system.exception.enums; +package cn.stylefeng.roses.kernel.system.exception.enums.organization; import cn.stylefeng.roses.kernel.rule.constants.RuleConstants; import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum; diff --git a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/exception/enums/OrganizationExceptionEnum.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/exception/enums/organization/OrganizationExceptionEnum.java similarity index 96% rename from kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/exception/enums/OrganizationExceptionEnum.java rename to kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/exception/enums/organization/OrganizationExceptionEnum.java index b560222a0..017e91edc 100644 --- a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/exception/enums/OrganizationExceptionEnum.java +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/exception/enums/organization/OrganizationExceptionEnum.java @@ -1,4 +1,4 @@ -package cn.stylefeng.roses.kernel.system.exception.enums; +package cn.stylefeng.roses.kernel.system.exception.enums.organization; import cn.stylefeng.roses.kernel.rule.constants.RuleConstants; import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum; diff --git a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/organization/DataScopeResponse.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/organization/DataScopeDTO.java similarity index 94% rename from kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/organization/DataScopeResponse.java rename to kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/organization/DataScopeDTO.java index 0a9efee64..5b972fa5e 100644 --- a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/organization/DataScopeResponse.java +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/organization/DataScopeDTO.java @@ -12,7 +12,7 @@ import java.util.Set; * @date 2020/11/6 11:30 */ @Data -public class DataScopeResponse { +public class DataScopeDTO { /** * 数据范围类型的响应结果 diff --git a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/organization/HrOrganizationResponse.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/organization/HrOrganizationDTO.java similarity index 95% rename from kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/organization/HrOrganizationResponse.java rename to kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/organization/HrOrganizationDTO.java index 92543ef1a..9a36335aa 100644 --- a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/organization/HrOrganizationResponse.java +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/organization/HrOrganizationDTO.java @@ -11,7 +11,7 @@ import java.math.BigDecimal; * @date 2020/11/04 11:05 */ @Data -public class HrOrganizationResponse { +public class HrOrganizationDTO { /** * 主键 diff --git a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/HrPositionRequest.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/organization/HrPositionRequest.java similarity index 96% rename from kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/HrPositionRequest.java rename to kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/organization/HrPositionRequest.java index fefaf662f..0c3fc68d9 100644 --- a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/HrPositionRequest.java +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/organization/HrPositionRequest.java @@ -1,4 +1,4 @@ -package cn.stylefeng.roses.kernel.system.pojo; +package cn.stylefeng.roses.kernel.system.pojo.organization; import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest; import cn.stylefeng.roses.kernel.validator.validators.status.StatusValue; diff --git a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/util/DataScopeUtil.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/util/DataScopeUtil.java index 5c42e8627..99a43d35f 100644 --- a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/util/DataScopeUtil.java +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/util/DataScopeUtil.java @@ -6,7 +6,7 @@ import cn.stylefeng.roses.kernel.auth.api.enums.DataScopeTypeEnum; import cn.stylefeng.roses.kernel.auth.api.exception.AuthException; import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser; import cn.stylefeng.roses.kernel.system.exception.SystemModularException; -import cn.stylefeng.roses.kernel.system.exception.enums.DataScopeExceptionEnum; +import cn.stylefeng.roses.kernel.system.exception.enums.organization.DataScopeExceptionEnum; import java.util.Set; diff --git a/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/controller/HrOrganizationController.java b/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/controller/HrOrganizationController.java index 20c48c216..8d54e60a0 100644 --- a/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/controller/HrOrganizationController.java +++ b/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/controller/HrOrganizationController.java @@ -40,18 +40,6 @@ public class HrOrganizationController { return new SuccessResponseData(); } - /** - * 编辑系统组织机构 - * - * @author fengshuonan - * @date 2020/11/04 11:05 - */ - @PostResource(name = "编辑系统组织机构", path = "/hrOrganization/edit") - public ResponseData edit(@RequestBody @Validated(HrOrganizationRequest.edit.class) HrOrganizationRequest hrOrganizationRequest) { - hrOrganizationService.edit(hrOrganizationRequest); - return new SuccessResponseData(); - } - /** * 删除系统组织机构 * @@ -64,6 +52,18 @@ public class HrOrganizationController { return new SuccessResponseData(); } + /** + * 编辑系统组织机构 + * + * @author fengshuonan + * @date 2020/11/04 11:05 + */ + @PostResource(name = "编辑系统组织机构", path = "/hrOrganization/edit") + public ResponseData edit(@RequestBody @Validated(HrOrganizationRequest.edit.class) HrOrganizationRequest hrOrganizationRequest) { + hrOrganizationService.edit(hrOrganizationRequest); + return new SuccessResponseData(); + } + /** * 修改组织机构状态 * @@ -110,18 +110,18 @@ public class HrOrganizationController { } /** - * 获取全部系统组织机构树,用于新增,编辑时选择上级节点 + * 获取全部系统组织机构树(antd vue版本,用于新增,编辑组织机构时选择上级节点) * * @author chenjinlong * @date 2021/01/05 15:55 */ @GetResource(name = "获取全部系统组织机构树", path = "/hrOrganization/tree") public ResponseData tree(HrOrganizationRequest hrOrganizationRequest) { - return new SuccessResponseData(hrOrganizationService.tree(hrOrganizationRequest)); + return new SuccessResponseData(hrOrganizationService.treeAntdv(hrOrganizationRequest)); } /** - * 获取全部系统组织机构树,用于新增,编辑时选择上级节点 + * 获取全部系统组织机构树(layui版本,用于新增,编辑组织机构时选择上级节点) * * @author chenjinlong * @date 2021/01/05 15:55 @@ -132,7 +132,7 @@ public class HrOrganizationController { } /** - * 获取zTree形式的组织机构树(用于角色配置数据范围类型,并且数据范围类型是指定组织机构时)(layui版本) + * 获取组织机构树(用于角色配置数据范围类型,并且数据范围类型是指定组织机构时)(layui版本) * * @author fengshuonan * @date 2021/1/9 18:37 @@ -143,7 +143,7 @@ public class HrOrganizationController { } /** - * 获取zTree形式的组织机构树(用于角色配置数据范围类型,并且数据范围类型是指定组织机构时)(antd vue版本) + * 获取组织机构树(用于角色配置数据范围类型,并且数据范围类型是指定组织机构时)(antd vue版本) * * @author fengshuonan * @date 2021/1/9 18:37 @@ -154,5 +154,4 @@ public class HrOrganizationController { return new SuccessResponseData(zTreeNodes); } - } diff --git a/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/controller/HrPositionController.java b/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/controller/HrPositionController.java index 3fa69cebc..b702e1b89 100644 --- a/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/controller/HrPositionController.java +++ b/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/controller/HrPositionController.java @@ -7,7 +7,7 @@ import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest; import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData; import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData; import cn.stylefeng.roses.kernel.system.modular.organization.service.HrPositionService; -import cn.stylefeng.roses.kernel.system.pojo.HrPositionRequest; +import cn.stylefeng.roses.kernel.system.pojo.organization.HrPositionRequest; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; @@ -39,18 +39,6 @@ public class HrPositionController { return new SuccessResponseData(); } - /** - * 编辑系统职位 - * - * @author chenjinlong - * @date 2020/11/04 11:07 - */ - @PostResource(name = "编辑系统职位", path = "/hrPosition/edit") - public ResponseData edit(@RequestBody @Validated(HrPositionRequest.edit.class) HrPositionRequest hrPositionRequest) { - hrPositionService.edit(hrPositionRequest); - return new SuccessResponseData(); - } - /** * 删除系统职位 * @@ -63,6 +51,18 @@ public class HrPositionController { return new SuccessResponseData(); } + /** + * 编辑系统职位 + * + * @author chenjinlong + * @date 2020/11/04 11:07 + */ + @PostResource(name = "编辑系统职位", path = "/hrPosition/edit") + public ResponseData edit(@RequestBody @Validated(HrPositionRequest.edit.class) HrPositionRequest hrPositionRequest) { + hrPositionService.edit(hrPositionRequest); + return new SuccessResponseData(); + } + /** * 更新职位状态 * diff --git a/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/factory/AntdvOrganizationFactory.java b/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/factory/AntdvOrganizationFactory.java new file mode 100644 index 000000000..507bebda2 --- /dev/null +++ b/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/factory/AntdvOrganizationFactory.java @@ -0,0 +1,29 @@ +package cn.stylefeng.roses.kernel.system.modular.organization.factory; + +import cn.stylefeng.roses.kernel.rule.tree.factory.node.DefaultTreeNode; +import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrOrganization; + +/** + * Antdv的组织机构树组装 + * + * @author fengshuonan + * @date 2021/2/8 20:32 + */ +public class AntdvOrganizationFactory { + + /** + * 实体转化为树节点 + * + * @author fengshuonan + * @date 2021/2/8 20:35 + */ + public static DefaultTreeNode parseTreeNode(HrOrganization organizationList) { + DefaultTreeNode orgTreeNode = new DefaultTreeNode(); + orgTreeNode.setId(String.valueOf(organizationList.getOrgId())); + orgTreeNode.setPId(String.valueOf(organizationList.getOrgParentId())); + orgTreeNode.setName(organizationList.getOrgName()); + orgTreeNode.setSort(organizationList.getOrgSort()); + return orgTreeNode; + } + +} diff --git a/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/factory/OrganizationFactory.java b/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/factory/LayuiOrganizationFactory.java similarity index 97% rename from kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/factory/OrganizationFactory.java rename to kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/factory/LayuiOrganizationFactory.java index cfc49e794..0bd4813ca 100644 --- a/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/factory/OrganizationFactory.java +++ b/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/factory/LayuiOrganizationFactory.java @@ -13,7 +13,7 @@ import java.util.List; * @author chenjinlong * @date 2021/1/6 21:03 */ -public class OrganizationFactory { +public class LayuiOrganizationFactory { /** * 实体转换 diff --git a/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/DataScopeService.java b/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/DataScopeService.java index 317d9b598..0b559c2c1 100644 --- a/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/DataScopeService.java +++ b/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/DataScopeService.java @@ -7,8 +7,8 @@ import cn.stylefeng.roses.kernel.system.RoleServiceApi; import cn.stylefeng.roses.kernel.system.UserOrgServiceApi; import cn.stylefeng.roses.kernel.system.UserServiceApi; import cn.stylefeng.roses.kernel.system.exception.SystemModularException; -import cn.stylefeng.roses.kernel.system.exception.enums.DataScopeExceptionEnum; -import cn.stylefeng.roses.kernel.system.pojo.organization.DataScopeResponse; +import cn.stylefeng.roses.kernel.system.exception.enums.organization.DataScopeExceptionEnum; +import cn.stylefeng.roses.kernel.system.pojo.organization.DataScopeDTO; import cn.stylefeng.roses.kernel.system.pojo.role.response.SysRoleResponse; import cn.stylefeng.roses.kernel.system.pojo.user.SysUserOrgResponse; import org.springframework.stereotype.Service; @@ -41,10 +41,10 @@ public class DataScopeService implements DataScopeApi { private DbOperatorApi dbOperatorApi; @Override - public DataScopeResponse getDataScope(Long userId, List sysRoles) { + public DataScopeDTO getDataScope(Long userId, List sysRoles) { // 初始化返回结果 - DataScopeResponse dataScopeResponse = new DataScopeResponse(); + DataScopeDTO dataScopeResponse = new DataScopeDTO(); Set userIds = new HashSet<>(); Set organizationIds = new HashSet<>(); diff --git a/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/HrOrganizationService.java b/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/HrOrganizationService.java index 6e3f8c21b..b924c21b4 100644 --- a/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/HrOrganizationService.java +++ b/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/HrOrganizationService.java @@ -29,15 +29,6 @@ public interface HrOrganizationService extends IService, Organiz */ void add(HrOrganizationRequest hrOrganizationRequest); - /** - * 编辑系统组织机构 - * - * @param hrOrganizationRequest 组织机构请求参数 - * @author fengshuonan - * @date 2020/11/04 11:05 - */ - void edit(HrOrganizationRequest hrOrganizationRequest); - /** * 删除系统组织机构 * @@ -47,6 +38,15 @@ public interface HrOrganizationService extends IService, Organiz */ void del(HrOrganizationRequest hrOrganizationRequest); + /** + * 编辑系统组织机构 + * + * @param hrOrganizationRequest 组织机构请求参数 + * @author fengshuonan + * @date 2020/11/04 11:05 + */ + void edit(HrOrganizationRequest hrOrganizationRequest); + /** * 修改组织机构状态 * @@ -86,19 +86,18 @@ public interface HrOrganizationService extends IService, Organiz */ List findList(HrOrganizationRequest hrOrganizationRequest); - /** - * 获取组织架构树 + * 获取全部系统组织机构树(antd vue版本,用于新增,编辑组织机构时选择上级节点) * * @param hrOrganizationRequest 查询参数 * @return 系统组织机构树 * @author fengshuonan * @date 2020/11/6 13:41 */ - List tree(HrOrganizationRequest hrOrganizationRequest); + List treeAntdv(HrOrganizationRequest hrOrganizationRequest); /** - * 获取组织架构树 + * 获取全部系统组织机构树(layui版本,用于新增,编辑组织机构时选择上级节点) * * @param hrOrganizationRequest 查询参数 * @return 系统组织机构树 @@ -107,16 +106,6 @@ public interface HrOrganizationService extends IService, Organiz */ List treeLayui(HrOrganizationRequest hrOrganizationRequest); - /** - * 查询所有参数组织架构id集合的所有层级的父id,包含父级的父级等 - * - * @param organizationIds 组织架构id集合 - * @return 被查询参数id集合的所有层级父级id,包含他们本身 - * @author fengshuonan - * @date 2020/11/6 14:24 - */ - Set findAllLevelParentIdsByOrganizations(Set organizationIds); - /** * 获取ztree形式的组织机构树(用于角色配置数据范围类型,并且数据范围类型是指定组织机构时)(layui版本) * @@ -128,4 +117,14 @@ public interface HrOrganizationService extends IService, Organiz */ List orgZTree(HrOrganizationRequest hrOrganizationRequest, boolean buildTree); + /** + * 查询所有参数组织架构id集合的所有层级的父id,包含父级的父级等 + * + * @param organizationIds 组织架构id集合 + * @return 被查询参数id集合的所有层级父级id,包含他们本身 + * @author fengshuonan + * @date 2020/11/6 14:24 + */ + Set findAllLevelParentIdsByOrganizations(Set organizationIds); + } diff --git a/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/HrPositionService.java b/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/HrPositionService.java index 9e7f1aa81..0f0a2230a 100644 --- a/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/HrPositionService.java +++ b/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/HrPositionService.java @@ -2,7 +2,7 @@ package cn.stylefeng.roses.kernel.system.modular.organization.service; import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult; import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrPosition; -import cn.stylefeng.roses.kernel.system.pojo.HrPositionRequest; +import cn.stylefeng.roses.kernel.system.pojo.organization.HrPositionRequest; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; @@ -81,4 +81,4 @@ public interface HrPositionService extends IService { */ PageResult findPage(HrPositionRequest hrPositionRequest); -} \ No newline at end of file +} diff --git a/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/impl/HrOrganizationServiceImpl.java b/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/impl/HrOrganizationServiceImpl.java index c66601b9f..344c9cabd 100644 --- a/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/impl/HrOrganizationServiceImpl.java +++ b/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/impl/HrOrganizationServiceImpl.java @@ -24,13 +24,14 @@ import cn.stylefeng.roses.kernel.system.RoleServiceApi; import cn.stylefeng.roses.kernel.system.UserOrgServiceApi; import cn.stylefeng.roses.kernel.system.UserServiceApi; import cn.stylefeng.roses.kernel.system.exception.SystemModularException; -import cn.stylefeng.roses.kernel.system.exception.enums.OrganizationExceptionEnum; +import cn.stylefeng.roses.kernel.system.exception.enums.organization.OrganizationExceptionEnum; import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrOrganization; -import cn.stylefeng.roses.kernel.system.modular.organization.factory.OrganizationFactory; +import cn.stylefeng.roses.kernel.system.modular.organization.factory.AntdvOrganizationFactory; +import cn.stylefeng.roses.kernel.system.modular.organization.factory.LayuiOrganizationFactory; import cn.stylefeng.roses.kernel.system.modular.organization.mapper.HrOrganizationMapper; import cn.stylefeng.roses.kernel.system.modular.organization.service.HrOrganizationService; +import cn.stylefeng.roses.kernel.system.pojo.organization.HrOrganizationDTO; import cn.stylefeng.roses.kernel.system.pojo.organization.HrOrganizationRequest; -import cn.stylefeng.roses.kernel.system.pojo.organization.HrOrganizationResponse; import cn.stylefeng.roses.kernel.system.pojo.organization.layui.LayuiOrganizationTreeNode; import cn.stylefeng.roses.kernel.system.util.DataScopeUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -87,27 +88,6 @@ public class HrOrganizationServiceImpl extends ServiceImpl orgList() { + public List treeAntdv(HrOrganizationRequest hrOrganizationRequest) { + // 定义返回结果 + List treeNodeList = CollectionUtil.newArrayList(); + // 组装节点 + List list = this.findListByDataScope(hrOrganizationRequest); + for (HrOrganization hrOrganization : list) { + DefaultTreeNode defaultTreeNode = AntdvOrganizationFactory.parseTreeNode(hrOrganization); + treeNodeList.add(defaultTreeNode); + } + + // 构建树并返回 + return new DefaultTreeBuildFactory().doTreeBuild(treeNodeList); + } + + @Override + public List treeLayui(HrOrganizationRequest hrOrganizationRequest) { + // 定义返回结果 + List treeNodeList = CollectionUtil.newArrayList(); + + // 组装节点 + List hrOrganizationList = this.findListByDataScope(hrOrganizationRequest); + for (HrOrganization hrOrganization : hrOrganizationList) { + LayuiOrganizationTreeNode treeNode = LayuiOrganizationFactory.parseOrganizationTreeNode(hrOrganization); + treeNodeList.add(treeNode); + } + + // 构建树并返回 + return new DefaultTreeBuildFactory().doTreeBuild(treeNodeList); + } + + @Override + public List orgZTree(HrOrganizationRequest hrOrganizationRequest, boolean buildTree) { + + // 获取角色id + Long roleId = hrOrganizationRequest.getRoleId(); + + // 获取所有组织机构列表 + LambdaQueryWrapper wrapper = createWrapper(hrOrganizationRequest); + List list = this.list(wrapper); + List zTreeNodes = LayuiOrganizationFactory.parseZTree(list); + + // 获取角色目前绑定的组织机构范围 + List roleDataScopes = roleServiceApi.getRoleDataScopes(ListUtil.toList(roleId)); + + // 设置绑定的组织机构范围为已选则状态 + for (ZTreeNode zTreeNode : zTreeNodes) { + if (roleDataScopes.contains(zTreeNode.getId())) { + zTreeNode.setChecked(true); + } + } + + if (buildTree) { + return new DefaultTreeBuildFactory().doTreeBuild(zTreeNodes); + } else { + return zTreeNodes; + } + } + + @Override + public Set findAllLevelParentIdsByOrganizations(Set organizationIds) { + + // 定义返回结果 + Set allLevelParentIds = new HashSet<>(organizationIds); + + // 查询出这些节点的pids字段 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.in(HrOrganization::getOrgId, organizationIds); + queryWrapper.select(HrOrganization::getOrgPids); + + List organizationList = this.list(queryWrapper); + if (organizationList == null || organizationList.isEmpty()) { + return allLevelParentIds; + } + + // 把所有的pids分割,并放入到set中 + for (HrOrganization hrOrganization : organizationList) { + + // 获取pids值 + String pids = hrOrganization.getOrgPids(); + + // 去掉所有的左中括号 + pids = StrUtil.removeAll(pids, SymbolConstant.LEFT_SQUARE_BRACKETS); + + // 去掉所有的右中括号 + pids = StrUtil.removeAll(pids, SymbolConstant.RIGHT_SQUARE_BRACKETS); + + // 按逗号分割这个字符串,得到pid的数组 + String[] finalPidArray = pids.split(StrUtil.COMMA); + + // 遍历这些值,放入到最终的set + for (String pid : finalPidArray) { + allLevelParentIds.add(Convert.toLong(pid)); + } + } + return allLevelParentIds; + } + + @Override + public List orgList() { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); @@ -200,20 +299,109 @@ public class HrOrganizationServiceImpl extends ServiceImpl mapper = e -> { - HrOrganizationResponse org = new HrOrganizationResponse(); + Function mapper = e -> { + HrOrganizationDTO org = new HrOrganizationDTO(); HrOrganization hrOrg = (HrOrganization) e; BeanUtil.copyProperties(hrOrg, org); return org; }; + // 返回数据 List list = this.list(queryWrapper); - List resultList = list.stream().filter(Objects::nonNull).map(mapper).collect(Collectors.toList()); - return resultList; + return list.stream().filter(Objects::nonNull).map(mapper).collect(Collectors.toList()); + } + + /** + * 创建组织架构的通用条件查询wrapper + * + * @author fengshuonan + * @date 2020/11/6 10:16 + */ + private LambdaQueryWrapper createWrapper(HrOrganizationRequest hrOrganizationRequest) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + + // 查询未删除状态的 + queryWrapper.eq(HrOrganization::getDelFlag, YesOrNotEnum.N.getCode()); + + // 根据排序升序排列,序号越小越在前 + queryWrapper.orderByAsc(HrOrganization::getOrgSort); + + if (ObjectUtil.isEmpty(hrOrganizationRequest)) { + return queryWrapper; + } + + String orgName = hrOrganizationRequest.getOrgName(); + String orgCode = hrOrganizationRequest.getOrgCode(); + Long orgParentId = hrOrganizationRequest.getOrgParentId(); + Long orgId = hrOrganizationRequest.getOrgId(); + + // 拼接组织机构名称条件 + queryWrapper.like(ObjectUtil.isNotEmpty(orgName), HrOrganization::getOrgName, orgName); + + // 拼接组织机构编码条件 + queryWrapper.eq(ObjectUtil.isNotEmpty(orgCode), HrOrganization::getOrgCode, orgCode); + + // 拼接父机构id查询条件 + if (ObjectUtil.isNotEmpty(orgParentId)) { + queryWrapper.and(qw -> { + qw.eq(HrOrganization::getOrgId, orgParentId).or().like(HrOrganization::getOrgPids, orgParentId); + }); + } + + // 拼接机构id查询条件 + queryWrapper.eq(ObjectUtil.isNotEmpty(orgId), HrOrganization::getOrgId, orgId); + + return queryWrapper; } + /** + * 获取系统组织机构 + * + * @author fengshuonan + * @date 2020/11/04 11:05 + */ + private HrOrganization queryOrganization(HrOrganizationRequest hrOrganizationRequest) { + HrOrganization hrOrganization = this.getById(hrOrganizationRequest.getOrgId()); + if (ObjectUtil.isEmpty(hrOrganization)) { + throw new SystemModularException(OrganizationExceptionEnum.CANT_FIND_ORG, hrOrganizationRequest.getOrgId()); + } + return hrOrganization; + } + + /** + * 填充该节点的pIds + *

+ * 如果pid是顶级节点,pids就是 [-1], + *

+ * 如果pid不是顶级节点,pids就是父节点的pids + [pid] + , + * + * @author fengshuonan + * @date 2020/11/5 13:45 + */ + private void fillParentIds(HrOrganization hrOrganization) { + if (TreeConstants.DEFAULT_PARENT_ID.equals(hrOrganization.getOrgParentId())) { + hrOrganization.setOrgPids(SymbolConstant.LEFT_SQUARE_BRACKETS + TreeConstants.DEFAULT_PARENT_ID + SymbolConstant.RIGHT_SQUARE_BRACKETS + SymbolConstant.COMMA); + } else { + // 获取父组织机构 + HrOrganizationRequest hrOrganizationRequest = new HrOrganizationRequest(); + hrOrganizationRequest.setOrgId(hrOrganization.getOrgId()); + HrOrganization parentOrganization = this.queryOrganization(hrOrganizationRequest); + + // 设置本节点的父ids为 (上一个节点的pids + (上级节点的id) ) + hrOrganization.setOrgPids( + parentOrganization.getOrgPids() + SymbolConstant.LEFT_SQUARE_BRACKETS + parentOrganization.getOrgId() + SymbolConstant.RIGHT_SQUARE_BRACKETS + SymbolConstant.COMMA); + } + } + + /** + * 根据数据范围获取组织机构列表 + * + * @author fengshuonan + * @date 2021/2/8 20:22 + */ private List findListByDataScope(HrOrganizationRequest hrOrganizationRequest) { LambdaQueryWrapper queryWrapper = this.createWrapper(hrOrganizationRequest); @@ -238,169 +426,7 @@ public class HrOrganizationServiceImpl extends ServiceImpl tree(HrOrganizationRequest hrOrganizationRequest) { - // 定义返回结果 - List treeNodeList = CollectionUtil.newArrayList(); - List list = this.findListByDataScope(hrOrganizationRequest); - // 组装节点 - for (HrOrganization hrOrganization : list) { - DefaultTreeNode orgTreeNode = new DefaultTreeNode(); - orgTreeNode.setId(String.valueOf(hrOrganization.getOrgId())); - orgTreeNode.setPId(String.valueOf(hrOrganization.getOrgParentId())); - orgTreeNode.setName(hrOrganization.getOrgName()); - orgTreeNode.setSort(hrOrganization.getOrgSort()); - treeNodeList.add(orgTreeNode); - } - // 构建树并返回 - return new DefaultTreeBuildFactory().doTreeBuild(treeNodeList); - } - - @Override - public List treeLayui(HrOrganizationRequest hrOrganizationRequest) { - // 定义返回结果 - List treeNodeList = CollectionUtil.newArrayList(); - List hrOrganizationList = this.findListByDataScope(hrOrganizationRequest); - hrOrganizationList.forEach(hrOrganization -> { - LayuiOrganizationTreeNode treeNode = OrganizationFactory.parseOrganizationTreeNode(hrOrganization); - treeNodeList.add(treeNode); - }); - return new DefaultTreeBuildFactory().doTreeBuild(treeNodeList); - } - - @Override - public Set findAllLevelParentIdsByOrganizations(Set organizationIds) { - - // 定义返回结果 - Set allLevelParentIds = new HashSet<>(organizationIds); - - // 查询出这些节点的pids字段 - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.in(HrOrganization::getOrgId, organizationIds); - queryWrapper.select(HrOrganization::getOrgPids); - - List organizationList = this.list(queryWrapper); - if (organizationList == null || organizationList.isEmpty()) { - return allLevelParentIds; - } - - // 把所有的pids分割,并放入到set中 - for (HrOrganization hrOrganization : organizationList) { - - // 获取pids值 - String pids = hrOrganization.getOrgPids(); - // 去掉所有的左中括号 - pids = StrUtil.removeAll(pids, SymbolConstant.LEFT_SQUARE_BRACKETS); - // 去掉所有的右中括号 - pids = StrUtil.removeAll(pids, SymbolConstant.RIGHT_SQUARE_BRACKETS); - // 按逗号分割这个字符串,得到pid的数组 - String[] finalPidArray = pids.split(StrUtil.COMMA); - - // 遍历这些值,放入到最终的set - for (String pid : finalPidArray) { - allLevelParentIds.add(Convert.toLong(pid)); - } - } - return allLevelParentIds; - } - - @Override - public List orgZTree(HrOrganizationRequest hrOrganizationRequest, boolean buildTree) { - - // 获取角色id - Long roleId = hrOrganizationRequest.getRoleId(); - - // 获取所有组织机构列表 - LambdaQueryWrapper wrapper = createWrapper(hrOrganizationRequest); - List list = this.list(wrapper); - List zTreeNodes = OrganizationFactory.parseZTree(list); - - // 获取角色目前绑定的组织机构范围 - List roleDataScopes = roleServiceApi.getRoleDataScopes(ListUtil.toList(roleId)); - - // 设置绑定的组织机构范围为已选则状态 - for (ZTreeNode zTreeNode : zTreeNodes) { - if (roleDataScopes.contains(zTreeNode.getId())) { - zTreeNode.setChecked(true); - } - } - - if (buildTree) { - return new DefaultTreeBuildFactory().doTreeBuild(zTreeNodes); - } else { - return zTreeNodes; - } - } - - /** - * 创建组织架构的通用条件查询wrapper - * - * @author fengshuonan - * @date 2020/11/6 10:16 - */ - private LambdaQueryWrapper createWrapper(HrOrganizationRequest hrOrganizationRequest) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - - String orgName = hrOrganizationRequest.getOrgName(); - String orgCode = hrOrganizationRequest.getOrgCode(); - Long orgParentId = hrOrganizationRequest.getOrgParentId(); - Long orgId = hrOrganizationRequest.getOrgId(); - queryWrapper.like(ObjectUtil.isNotEmpty(orgName), HrOrganization::getOrgName, orgName); - queryWrapper.eq(ObjectUtil.isNotEmpty(orgCode), HrOrganization::getOrgCode, orgCode); - // 拼接机构id查询条件 - queryWrapper.eq(ObjectUtil.isNotEmpty(orgId), HrOrganization::getOrgId, orgId); - // 拼接父机构id查询条件 - if (ObjectUtil.isNotEmpty(orgParentId)) { - queryWrapper.and(qw -> { - qw.eq(HrOrganization::getOrgId, orgParentId).or().like(HrOrganization::getOrgPids, orgParentId); - }); - } - // 查询未删除状态的 - queryWrapper.eq(HrOrganization::getDelFlag, YesOrNotEnum.N.getCode()); - // 根据排序升序排列,序号越小越在前 - queryWrapper.orderByAsc(HrOrganization::getOrgSort); - return queryWrapper; - } - - - /** - * 获取系统组织机构 - * - * @author fengshuonan - * @date 2020/11/04 11:05 - */ - private HrOrganization queryOrganization(HrOrganizationRequest hrOrganizationRequest) { - HrOrganization hrOrganization = this.getById(hrOrganizationRequest.getOrgId()); - if (ObjectUtil.isEmpty(hrOrganization)) { - throw new SystemModularException(OrganizationExceptionEnum.CANT_FIND_ORG, hrOrganizationRequest.getOrgId()); - } - return hrOrganization; - } - - /** - * 填充该节点的pIds - * - * @author fengshuonan - * @date 2020/11/5 13:45 - */ - private void fillParentIds(HrOrganization hrOrganization) { - - // 如果是一级节点(一级节点的pid是0) - if (hrOrganization.getOrgParentId().equals(TreeConstants.DEFAULT_PARENT_ID)) { - // 设置一级节点的pid为[0], - hrOrganization.setOrgPids(SymbolConstant.LEFT_SQUARE_BRACKETS + TreeConstants.DEFAULT_PARENT_ID + SymbolConstant.RIGHT_SQUARE_BRACKETS + SymbolConstant.COMMA); - } else { - // 获取父组织机构 - HrOrganization parentOrganization = this.getById(hrOrganization.getOrgParentId()); - - // 设置本节点的父ids为 (上一个节点的pids + (上级节点的id) ) - hrOrganization.setOrgPids( - parentOrganization.getOrgPids() + SymbolConstant.LEFT_SQUARE_BRACKETS + parentOrganization.getOrgId() + SymbolConstant.RIGHT_SQUARE_BRACKETS + SymbolConstant.COMMA); - } - } - } diff --git a/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/impl/HrPositionServiceImpl.java b/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/impl/HrPositionServiceImpl.java index 4d9c45097..6c36361b6 100644 --- a/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/impl/HrPositionServiceImpl.java +++ b/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/impl/HrPositionServiceImpl.java @@ -14,7 +14,7 @@ import cn.stylefeng.roses.kernel.system.exception.enums.PositionExceptionEnum; import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrPosition; import cn.stylefeng.roses.kernel.system.modular.organization.mapper.HrPositionMapper; import cn.stylefeng.roses.kernel.system.modular.organization.service.HrPositionService; -import cn.stylefeng.roses.kernel.system.pojo.HrPositionRequest; +import cn.stylefeng.roses.kernel.system.pojo.organization.HrPositionRequest; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -46,13 +46,6 @@ public class HrPositionServiceImpl extends ServiceImpl createWrapper(HrPositionRequest hrPositionRequest) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + // 查询未删除状态的 + queryWrapper.eq(HrPosition::getDelFlag, YesOrNotEnum.N.getCode()); + + // 根据排序升序排列,序号越小越在前 + queryWrapper.orderByAsc(HrPosition::getPositionSort); + + if (ObjectUtil.isEmpty(hrPositionRequest)) { + return queryWrapper; + } + Long positionId = hrPositionRequest.getPositionId(); String positionName = hrPositionRequest.getPositionName(); String positionCode = hrPositionRequest.getPositionCode(); @@ -129,13 +138,7 @@ public class HrPositionServiceImpl extends ServiceImpl roleResponseList, - DataScopeResponse dataScopeResponse, + DataScopeDTO dataScopeResponse, SysUserOrgResponse userOrgInfo, Set resourceUrlsListByCodes, Set roleButtonCodes) { diff --git a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/SysUserDataScopeService.java b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/SysUserDataScopeService.java index dac7ce3cc..c73f3ef71 100644 --- a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/SysUserDataScopeService.java +++ b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/SysUserDataScopeService.java @@ -15,7 +15,6 @@ import java.util.List; */ public interface SysUserDataScopeService extends IService { - /** * 新增 * diff --git a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserServiceImpl.java b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserServiceImpl.java index 1f5ae8765..3eca6084a 100644 --- a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserServiceImpl.java +++ b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserServiceImpl.java @@ -39,8 +39,8 @@ import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserDataScopeSer import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserOrgService; import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserRoleService; import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserService; -import cn.stylefeng.roses.kernel.system.pojo.organization.DataScopeResponse; -import cn.stylefeng.roses.kernel.system.pojo.organization.HrOrganizationResponse; +import cn.stylefeng.roses.kernel.system.pojo.organization.DataScopeDTO; +import cn.stylefeng.roses.kernel.system.pojo.organization.HrOrganizationDTO; import cn.stylefeng.roses.kernel.system.pojo.role.response.SysRoleResponse; import cn.stylefeng.roses.kernel.system.pojo.user.*; import cn.stylefeng.roses.kernel.system.pojo.user.request.OnlineUserRequest; @@ -430,7 +430,7 @@ public class SysUserServiceImpl extends ServiceImpl impl List roleResponseList = roleServiceApi.getRolesByIds(roleIds); // 3. 获取用户的数据范围 - DataScopeResponse dataScopeResponse = dataScopeApi.getDataScope(userId, roleResponseList); + DataScopeDTO dataScopeResponse = dataScopeApi.getDataScope(userId, roleResponseList); // 4. 获取用户的组织机构和职位信息 SysUserOrgResponse userOrgInfo = sysUserOrgService.getUserOrgInfo(userId); @@ -594,9 +594,9 @@ public class SysUserServiceImpl extends ServiceImpl impl public List userSelectTree(SysUserRequest sysUserRequest) { // 定义返回结果 List treeNodeList = CollectionUtil.newArrayList(); - List orgList = organizationServiceApi.orgList(); + List orgList = organizationServiceApi.orgList(); UserSelectTreeNode orgTreeNode; - for (HrOrganizationResponse hrOrganization : orgList) { + for (HrOrganizationDTO hrOrganization : orgList) { orgTreeNode = new UserSelectTreeNode(); orgTreeNode.setId(String.valueOf(hrOrganization.getOrgId())); orgTreeNode.setPId(String.valueOf(hrOrganization.getOrgParentId()));