mirror of https://gitee.com/stylefeng/roses
【7.0.2】合并组织机构树获取的接口
parent
06319b271c
commit
8552a982cf
|
@ -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.factory.base.AbstractTreeNode;
|
||||||
import cn.stylefeng.roses.kernel.rule.tree.xmtree.base.AbstractXmSelectNode;
|
import cn.stylefeng.roses.kernel.rule.tree.xmtree.base.AbstractXmSelectNode;
|
||||||
|
@ -7,13 +7,13 @@ import lombok.Data;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layui 机构树
|
* 组织机构树节点
|
||||||
*
|
*
|
||||||
* @author chenjinlong
|
* @author chenjinlong
|
||||||
* @date 2020/12/27 18:36
|
* @date 2020/12/27 18:36
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class LayuiOrganizationTreeNode implements AbstractTreeNode, AbstractXmSelectNode {
|
public class OrganizationTreeNode implements AbstractTreeNode, AbstractXmSelectNode {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 父id,一级节点父id是0
|
* 父id,一级节点父id是0
|
||||||
|
@ -38,7 +38,7 @@ public class LayuiOrganizationTreeNode implements AbstractTreeNode, AbstractXmSe
|
||||||
/**
|
/**
|
||||||
* 子节点的集合
|
* 子节点的集合
|
||||||
*/
|
*/
|
||||||
private List<LayuiOrganizationTreeNode> children;
|
private List<OrganizationTreeNode> children;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNodeId() {
|
public String getNodeId() {
|
|
@ -110,25 +110,14 @@ public class HrOrganizationController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取全部系统组织机构树(antd vue版本,用于新增,编辑组织机构时选择上级节点)
|
* 获取全部系统组织机构树(用于新增,编辑组织机构时选择上级节点,用于获取用户管理界面左侧组织机构树)
|
||||||
*
|
*
|
||||||
* @author chenjinlong
|
* @author chenjinlong
|
||||||
* @date 2021/01/05 15:55
|
* @date 2021/01/05 15:55
|
||||||
*/
|
*/
|
||||||
@GetResource(name = "获取全部系统组织机构树", path = "/hrOrganization/tree")
|
@GetResource(name = "获取全部系统组织机构树", path = "/hrOrganization/tree")
|
||||||
public ResponseData tree(HrOrganizationRequest hrOrganizationRequest) {
|
public ResponseData organizationTree(HrOrganizationRequest hrOrganizationRequest) {
|
||||||
return new SuccessResponseData(hrOrganizationService.treeAntdv(hrOrganizationRequest));
|
return new SuccessResponseData(hrOrganizationService.organizationTree(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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,8 +1,8 @@
|
||||||
package cn.stylefeng.roses.kernel.system.modular.organization.factory;
|
package cn.stylefeng.roses.kernel.system.modular.organization.factory;
|
||||||
|
|
||||||
import cn.stylefeng.roses.kernel.rule.tree.ztree.ZTreeNode;
|
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.modular.organization.entity.HrOrganization;
|
||||||
import cn.stylefeng.roses.kernel.system.api.pojo.organization.layui.LayuiOrganizationTreeNode;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -13,7 +13,7 @@ import java.util.List;
|
||||||
* @author chenjinlong
|
* @author chenjinlong
|
||||||
* @date 2021/1/6 21:03
|
* @date 2021/1/6 21:03
|
||||||
*/
|
*/
|
||||||
public class LayuiOrganizationFactory {
|
public class OrganizationFactory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实体转换
|
* 实体转换
|
||||||
|
@ -23,8 +23,8 @@ public class LayuiOrganizationFactory {
|
||||||
* @author chenjinlong
|
* @author chenjinlong
|
||||||
* @date 2021/1/5 21:07
|
* @date 2021/1/5 21:07
|
||||||
*/
|
*/
|
||||||
public static LayuiOrganizationTreeNode parseOrganizationTreeNode(HrOrganization hrOrganization) {
|
public static OrganizationTreeNode parseOrganizationTreeNode(HrOrganization hrOrganization) {
|
||||||
LayuiOrganizationTreeNode treeNode = new LayuiOrganizationTreeNode();
|
OrganizationTreeNode treeNode = new OrganizationTreeNode();
|
||||||
treeNode.setId(hrOrganization.getOrgId());
|
treeNode.setId(hrOrganization.getOrgId());
|
||||||
treeNode.setParentId(hrOrganization.getOrgParentId());
|
treeNode.setParentId(hrOrganization.getOrgParentId());
|
||||||
treeNode.setTitle(hrOrganization.getOrgName());
|
treeNode.setTitle(hrOrganization.getOrgName());
|
|
@ -1,12 +1,11 @@
|
||||||
package cn.stylefeng.roses.kernel.system.modular.organization.service;
|
package cn.stylefeng.roses.kernel.system.modular.organization.service;
|
||||||
|
|
||||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
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.rule.tree.ztree.ZTreeNode;
|
||||||
import cn.stylefeng.roses.kernel.system.api.OrganizationServiceApi;
|
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.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 com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -87,24 +86,14 @@ public interface HrOrganizationService extends IService<HrOrganization>, Organiz
|
||||||
List<HrOrganization> findList(HrOrganizationRequest hrOrganizationRequest);
|
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 查询参数
|
* @param hrOrganizationRequest 查询参数
|
||||||
* @return 系统组织机构树
|
* @return 系统组织机构树
|
||||||
* @author chenjinlong
|
* @author chenjinlong
|
||||||
* @date 2020/11/6 13:41
|
* @date 2020/11/6 13:41
|
||||||
*/
|
*/
|
||||||
List<LayuiOrganizationTreeNode> treeLayui(HrOrganizationRequest hrOrganizationRequest);
|
List<OrganizationTreeNode> organizationTree(HrOrganizationRequest hrOrganizationRequest);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取ztree形式的组织机构树(用于角色配置数据范围类型,并且数据范围类型是指定组织机构时)(layui版本)
|
* 获取ztree形式的组织机构树(用于角色配置数据范围类型,并且数据范围类型是指定组织机构时)(layui版本)
|
||||||
|
|
|
@ -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.StatusEnum;
|
||||||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
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.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.rule.tree.ztree.ZTreeNode;
|
||||||
import cn.stylefeng.roses.kernel.system.api.RoleDataScopeServiceApi;
|
import cn.stylefeng.roses.kernel.system.api.RoleDataScopeServiceApi;
|
||||||
import cn.stylefeng.roses.kernel.system.api.RoleServiceApi;
|
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.exception.enums.organization.OrganizationExceptionEnum;
|
||||||
import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrOrganizationDTO;
|
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.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.api.util.DataScopeUtil;
|
||||||
import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrOrganization;
|
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.OrganizationFactory;
|
||||||
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.mapper.HrOrganizationMapper;
|
||||||
import cn.stylefeng.roses.kernel.system.modular.organization.service.HrOrganizationService;
|
import cn.stylefeng.roses.kernel.system.modular.organization.service.HrOrganizationService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
@ -166,35 +164,20 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DefaultTreeNode> treeAntdv(HrOrganizationRequest hrOrganizationRequest) {
|
public List<OrganizationTreeNode> organizationTree(HrOrganizationRequest hrOrganizationRequest) {
|
||||||
|
|
||||||
// 定义返回结果
|
// 定义返回结果
|
||||||
List<DefaultTreeNode> treeNodeList = CollectionUtil.newArrayList();
|
List<OrganizationTreeNode> 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<HrOrganization> hrOrganizationList = this.findListByDataScope(hrOrganizationRequest);
|
List<HrOrganization> hrOrganizationList = this.findListByDataScope(hrOrganizationRequest);
|
||||||
for (HrOrganization hrOrganization : hrOrganizationList) {
|
for (HrOrganization hrOrganization : hrOrganizationList) {
|
||||||
LayuiOrganizationTreeNode treeNode = LayuiOrganizationFactory.parseOrganizationTreeNode(hrOrganization);
|
OrganizationTreeNode treeNode = OrganizationFactory.parseOrganizationTreeNode(hrOrganization);
|
||||||
treeNodeList.add(treeNode);
|
treeNodeList.add(treeNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构建树并返回
|
// 构建树并返回
|
||||||
return new DefaultTreeBuildFactory<LayuiOrganizationTreeNode>().doTreeBuild(treeNodeList);
|
return new DefaultTreeBuildFactory<OrganizationTreeNode>().doTreeBuild(treeNodeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -206,7 +189,7 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
|
||||||
// 获取所有组织机构列表
|
// 获取所有组织机构列表
|
||||||
LambdaQueryWrapper<HrOrganization> wrapper = createWrapper(hrOrganizationRequest);
|
LambdaQueryWrapper<HrOrganization> wrapper = createWrapper(hrOrganizationRequest);
|
||||||
List<HrOrganization> list = this.list(wrapper);
|
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));
|
List<Long> roleDataScopes = roleServiceApi.getRoleDataScopes(ListUtil.toList(roleId));
|
||||||
|
|
Loading…
Reference in New Issue