diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/controller/CommonOrgController.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/controller/CommonOrgController.java index 490414d94..198925121 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/controller/CommonOrgController.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/controller/CommonOrgController.java @@ -9,12 +9,12 @@ import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource; import cn.stylefeng.roses.kernel.sys.modular.org.entity.HrOrganization; 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.response.CommonOrgTreeResponse; import cn.stylefeng.roses.kernel.sys.modular.org.service.HrOrganizationService; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; -import java.util.List; /** * 通用组织机构接口 @@ -40,7 +40,7 @@ public class CommonOrgController { * @since 2023/6/11 10:31 */ @PostResource(name = "通用获取组织机构树", path = "/common/org/tree") - public ResponseData> commonOrgTree(@RequestBody CommonOrgTreeRequest commonOrgTreeRequest) { + public ResponseData commonOrgTree(@RequestBody CommonOrgTreeRequest commonOrgTreeRequest) { return new SuccessResponseData<>(hrOrganizationService.commonOrgTree(commonOrgTreeRequest)); } 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 f83b26d21..7645913c0 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 @@ -154,13 +154,6 @@ public class HrOrganization extends BaseExpandFieldEntity implements AbstractTre @ChineseDescription("是否有子级:true-有子级,false-无子级") private Boolean haveSubOrgFlag = false; - /** - * 是否要展开显示:true-展开本节点显示,false-不展开显示 - */ - @TableField(exist = false) - @ChineseDescription("是否要展开显示:true-展开本节点显示,false-不展开显示") - private Boolean expandShowFlag = false; - @Override public String getNodeId() { if (this.orgId == null) { diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/pojo/response/CommonOrgTreeResponse.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/pojo/response/CommonOrgTreeResponse.java new file mode 100644 index 000000000..ba716a1a4 --- /dev/null +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/pojo/response/CommonOrgTreeResponse.java @@ -0,0 +1,40 @@ +package cn.stylefeng.roses.kernel.sys.modular.org.pojo.response; + +import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription; +import cn.stylefeng.roses.kernel.sys.modular.org.entity.HrOrganization; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * 组织机构树响应结果 + * + * @author fengshuonan + * @since 2023/7/17 11:04 + */ +@Data +public class CommonOrgTreeResponse { + + /** + * 组织机构树列表 + */ + @ChineseDescription("组织机构树列表") + private List orgTreeList; + + /** + * 展开显示组织机构id的列表 + */ + @ChineseDescription("展开显示组织机构id的列表") + private List expandOrgIdList = new ArrayList<>(); + + public CommonOrgTreeResponse() { + + } + + public CommonOrgTreeResponse(List orgTreeList, List expandOrgIdList) { + this.orgTreeList = orgTreeList; + this.expandOrgIdList = expandOrgIdList; + } + +} diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/service/HrOrganizationService.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/service/HrOrganizationService.java index 51f775c42..026b22e8f 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/service/HrOrganizationService.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/org/service/HrOrganizationService.java @@ -6,6 +6,7 @@ import cn.stylefeng.roses.kernel.sys.api.pojo.org.CompanyDeptDTO; import cn.stylefeng.roses.kernel.sys.modular.org.entity.HrOrganization; 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.response.CommonOrgTreeResponse; import cn.stylefeng.roses.kernel.sys.modular.org.pojo.response.HomeCompanyInfo; import com.baomidou.mybatisplus.extension.service.IService; @@ -102,7 +103,7 @@ public interface HrOrganizationService extends IService, Organiz * @author fengshuonan * @since 2023/6/11 10:40 */ - List commonOrgTree(CommonOrgTreeRequest commonOrgTreeRequest); + CommonOrgTreeResponse commonOrgTree(CommonOrgTreeRequest commonOrgTreeRequest); /** * 根据组织机构id,获取对应的具体的公司和部门信息 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 40f515221..eb695299d 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 @@ -29,6 +29,7 @@ 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.response.CommonOrgTreeResponse; import cn.stylefeng.roses.kernel.sys.modular.org.pojo.response.HomeCompanyInfo; import cn.stylefeng.roses.kernel.sys.modular.org.service.HrOrganizationService; import cn.stylefeng.roses.kernel.sys.modular.position.service.HrPositionService; @@ -197,7 +198,7 @@ public class HrOrganizationServiceImpl extends ServiceImpl commonOrgTree(CommonOrgTreeRequest commonOrgTreeRequest) { + public CommonOrgTreeResponse commonOrgTree(CommonOrgTreeRequest commonOrgTreeRequest) { // 如果查询带组织机构名称的搜索,则清空其他条件 if (ObjectUtil.isNotEmpty(commonOrgTreeRequest.getSearchText())) { @@ -217,7 +218,7 @@ public class HrOrganizationServiceImpl extends ServiceImpl hrOrganizationList = this.list(wrapper); if (ObjectUtil.isEmpty(hrOrganizationList)) { - return hrOrganizationList; + return new CommonOrgTreeResponse(hrOrganizationList, new ArrayList<>()); } // 如果查询条件不为空,则把相关的查询结果的父级也查询出来,组成一颗完整树 @@ -250,7 +251,11 @@ public class HrOrganizationServiceImpl extends ServiceImpl expandOrgIds = new ArrayList<>(); + this.fillExpandFlag(newNotRepeatList, expandOrgIds); + + return new CommonOrgTreeResponse(newNotRepeatList, expandOrgIds); } @Override @@ -612,8 +617,6 @@ public class HrOrganizationServiceImpl extends ServiceImpl + * 判定是否展开,如果有children则展开 + * + * @author fengshuonan + * @since 2023/7/17 11:11 + */ + private void fillExpandFlag(List organizations, List expandOrgIds) { + + if (ObjectUtil.isEmpty(organizations)) { + return; + } + + for (HrOrganization organization : organizations) { + + Long orgId = organization.getOrgId(); + + // 如果有children则将展开标识填充,并继续向下递归填充 + if (ObjectUtil.isNotEmpty(organization.getChildren())) { + expandOrgIds.add(orgId); + + // 搜集子集的children的展开标识 + fillExpandFlag(organization.getChildren(), expandOrgIds); + } + } + } + /** * 计算获取上级组织机构id *