【7.0.2】合并组织机构树获取的接口

pull/12/head
fengshuonan 2021-03-17 23:14:29 +08:00
parent 06319b271c
commit 8552a982cf
6 changed files with 23 additions and 91 deletions

View File

@ -1,4 +1,4 @@
package cn.stylefeng.roses.kernel.system.api.pojo.organization.layui;
package cn.stylefeng.roses.kernel.system.api.pojo.organization;
import cn.stylefeng.roses.kernel.rule.tree.factory.base.AbstractTreeNode;
import cn.stylefeng.roses.kernel.rule.tree.xmtree.base.AbstractXmSelectNode;
@ -7,13 +7,13 @@ import lombok.Data;
import java.util.List;
/**
* Layui
*
*
* @author chenjinlong
* @date 2020/12/27 18:36
*/
@Data
public class LayuiOrganizationTreeNode implements AbstractTreeNode, AbstractXmSelectNode {
public class OrganizationTreeNode implements AbstractTreeNode, AbstractXmSelectNode {
/**
* idid0
@ -38,7 +38,7 @@ public class LayuiOrganizationTreeNode implements AbstractTreeNode, AbstractXmSe
/**
*
*/
private List<LayuiOrganizationTreeNode> children;
private List<OrganizationTreeNode> children;
@Override
public String getNodeId() {

View File

@ -110,25 +110,14 @@ 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.treeAntdv(hrOrganizationRequest));
}
/**
* layui
*
* @author chenjinlong
* @date 2021/01/05 15:55
*/
@GetResource(name = "获取全部系统组织机构树", path = "/hrOrganization/treeLayui")
public ResponseData treeLayui(HrOrganizationRequest hrOrganizationRequest) {
return new SuccessResponseData(hrOrganizationService.treeLayui(hrOrganizationRequest));
public ResponseData organizationTree(HrOrganizationRequest hrOrganizationRequest) {
return new SuccessResponseData(hrOrganizationService.organizationTree(hrOrganizationRequest));
}
/**

View File

@ -1,29 +0,0 @@
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;
}
}

View File

@ -1,8 +1,8 @@
package cn.stylefeng.roses.kernel.system.modular.organization.factory;
import cn.stylefeng.roses.kernel.rule.tree.ztree.ZTreeNode;
import cn.stylefeng.roses.kernel.system.api.pojo.organization.OrganizationTreeNode;
import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrOrganization;
import cn.stylefeng.roses.kernel.system.api.pojo.organization.layui.LayuiOrganizationTreeNode;
import java.util.ArrayList;
import java.util.List;
@ -13,7 +13,7 @@ import java.util.List;
* @author chenjinlong
* @date 2021/1/6 21:03
*/
public class LayuiOrganizationFactory {
public class OrganizationFactory {
/**
*
@ -23,8 +23,8 @@ public class LayuiOrganizationFactory {
* @author chenjinlong
* @date 2021/1/5 21:07
*/
public static LayuiOrganizationTreeNode parseOrganizationTreeNode(HrOrganization hrOrganization) {
LayuiOrganizationTreeNode treeNode = new LayuiOrganizationTreeNode();
public static OrganizationTreeNode parseOrganizationTreeNode(HrOrganization hrOrganization) {
OrganizationTreeNode treeNode = new OrganizationTreeNode();
treeNode.setId(hrOrganization.getOrgId());
treeNode.setParentId(hrOrganization.getOrgParentId());
treeNode.setTitle(hrOrganization.getOrgName());

View File

@ -1,12 +1,11 @@
package cn.stylefeng.roses.kernel.system.modular.organization.service;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.tree.factory.node.DefaultTreeNode;
import cn.stylefeng.roses.kernel.rule.tree.ztree.ZTreeNode;
import cn.stylefeng.roses.kernel.system.api.OrganizationServiceApi;
import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrOrganization;
import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrOrganizationRequest;
import cn.stylefeng.roses.kernel.system.api.pojo.organization.layui.LayuiOrganizationTreeNode;
import cn.stylefeng.roses.kernel.system.api.pojo.organization.OrganizationTreeNode;
import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrOrganization;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
@ -87,24 +86,14 @@ public interface HrOrganizationService extends IService<HrOrganization>, Organiz
List<HrOrganization> findList(HrOrganizationRequest hrOrganizationRequest);
/**
* antd vue
*
* @param hrOrganizationRequest
* @return
* @author fengshuonan
* @date 2020/11/6 13:41
*/
List<DefaultTreeNode> treeAntdv(HrOrganizationRequest hrOrganizationRequest);
/**
* layui
*
*
* @param hrOrganizationRequest
* @return
* @author chenjinlong
* @date 2020/11/6 13:41
*/
List<LayuiOrganizationTreeNode> treeLayui(HrOrganizationRequest hrOrganizationRequest);
List<OrganizationTreeNode> organizationTree(HrOrganizationRequest hrOrganizationRequest);
/**
* ztreelayui

View File

@ -17,7 +17,6 @@ import cn.stylefeng.roses.kernel.rule.constants.TreeConstants;
import cn.stylefeng.roses.kernel.rule.enums.StatusEnum;
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
import cn.stylefeng.roses.kernel.rule.tree.factory.DefaultTreeBuildFactory;
import cn.stylefeng.roses.kernel.rule.tree.factory.node.DefaultTreeNode;
import cn.stylefeng.roses.kernel.rule.tree.ztree.ZTreeNode;
import cn.stylefeng.roses.kernel.system.api.RoleDataScopeServiceApi;
import cn.stylefeng.roses.kernel.system.api.RoleServiceApi;
@ -27,11 +26,10 @@ import cn.stylefeng.roses.kernel.system.api.exception.SystemModularException;
import cn.stylefeng.roses.kernel.system.api.exception.enums.organization.OrganizationExceptionEnum;
import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrOrganizationDTO;
import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrOrganizationRequest;
import cn.stylefeng.roses.kernel.system.api.pojo.organization.layui.LayuiOrganizationTreeNode;
import cn.stylefeng.roses.kernel.system.api.pojo.organization.OrganizationTreeNode;
import cn.stylefeng.roses.kernel.system.api.util.DataScopeUtil;
import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrOrganization;
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.factory.OrganizationFactory;
import cn.stylefeng.roses.kernel.system.modular.organization.mapper.HrOrganizationMapper;
import cn.stylefeng.roses.kernel.system.modular.organization.service.HrOrganizationService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -166,35 +164,20 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
}
@Override
public List<DefaultTreeNode> treeAntdv(HrOrganizationRequest hrOrganizationRequest) {
public List<OrganizationTreeNode> organizationTree(HrOrganizationRequest hrOrganizationRequest) {
// 定义返回结果
List<DefaultTreeNode> treeNodeList = CollectionUtil.newArrayList();
// 组装节点
List<HrOrganization> list = this.findListByDataScope(hrOrganizationRequest);
for (HrOrganization hrOrganization : list) {
DefaultTreeNode defaultTreeNode = AntdvOrganizationFactory.parseTreeNode(hrOrganization);
treeNodeList.add(defaultTreeNode);
}
// 构建树并返回
return new DefaultTreeBuildFactory<DefaultTreeNode>().doTreeBuild(treeNodeList);
}
@Override
public List<LayuiOrganizationTreeNode> treeLayui(HrOrganizationRequest hrOrganizationRequest) {
// 定义返回结果
List<LayuiOrganizationTreeNode> treeNodeList = CollectionUtil.newArrayList();
List<OrganizationTreeNode> treeNodeList = CollectionUtil.newArrayList();
// 组装节点
List<HrOrganization> hrOrganizationList = this.findListByDataScope(hrOrganizationRequest);
for (HrOrganization hrOrganization : hrOrganizationList) {
LayuiOrganizationTreeNode treeNode = LayuiOrganizationFactory.parseOrganizationTreeNode(hrOrganization);
OrganizationTreeNode treeNode = OrganizationFactory.parseOrganizationTreeNode(hrOrganization);
treeNodeList.add(treeNode);
}
// 构建树并返回
return new DefaultTreeBuildFactory<LayuiOrganizationTreeNode>().doTreeBuild(treeNodeList);
return new DefaultTreeBuildFactory<OrganizationTreeNode>().doTreeBuild(treeNodeList);
}
@Override
@ -206,7 +189,7 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
// 获取所有组织机构列表
LambdaQueryWrapper<HrOrganization> wrapper = createWrapper(hrOrganizationRequest);
List<HrOrganization> list = this.list(wrapper);
List<ZTreeNode> zTreeNodes = LayuiOrganizationFactory.parseZTree(list);
List<ZTreeNode> zTreeNodes = OrganizationFactory.parseZTree(list);
// 获取角色目前绑定的组织机构范围
List<Long> roleDataScopes = roleServiceApi.getRoleDataScopes(ListUtil.toList(roleId));