|  | @@ -157,13 +157,28 @@ public class SharePathServiceImpl implements SharePathService {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public TreeNode getTree(Long userId, Integer minDepth, Integer maxDepth) {
 | 
	
		
			
				|  |  | +    public TreeNode getTree(Long userId, Integer maxDepth) {
 | 
	
		
			
				|  |  |          // 如果user为空, 则查询全部信息
 | 
	
		
			
				|  |  |          if (userId == null) {
 | 
	
		
			
				|  |  |              userId = PT_ID;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          DuserDO sharePathDO = duserService.getDuserByUser(userId);
 | 
	
		
			
				|  |  | -        List<TreeNode> treeNodes = sharePathMapper.selectDescendants(userId, minDepth, maxDepth);
 | 
	
		
			
				|  |  | +        // 查询层级范围
 | 
	
		
			
				|  |  | +        List<SharePathDO> sharePathDOS = sharePathMapper.selectList(new LambdaQueryWrapperX<SharePathDO>().eq(SharePathDO::getAncestor, userId)
 | 
	
		
			
				|  |  | +                .between(SharePathDO::getDepth, 1, maxDepth));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<TreeNode> deep = sharePathDO2TreeNode(sharePathDOS);
 | 
	
		
			
				|  |  | +        if (maxDepth > 1) {
 | 
	
		
			
				|  |  | +            List<Long> descs = sharePathDOS.stream().filter(k -> k.getDepth() > 1).map(SharePathDO::getDescendant).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +            // 获取大于1层级的数据
 | 
	
		
			
				|  |  | +            List<SharePathDO> descList = sharePathMapper.selectList(new LambdaQueryWrapperX<SharePathDO>().ne(SharePathDO::getAncestor, 1).in(SharePathDO::getDescendant, descs));
 | 
	
		
			
				|  |  | +            List<TreeNode> treeNodes1 = sharePathDO2TreeNode(descList);
 | 
	
		
			
				|  |  | +            deep = deep.stream().filter(k -> k.getDeep() == 1).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +            deep.addAll(treeNodes1);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        // 整合结构
 | 
	
		
			
				|  |  | +        List<TreeNode> treeNodes = listWithTree(deep, userId);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          TreeNode build = TreeNode.builder()
 | 
	
		
			
				|  |  |                  .phone(sharePathDO.getMobile())
 | 
	
		
			
				|  |  |                  .name(sharePathDO.getName())
 | 
	
	
		
			
				|  | @@ -178,6 +193,37 @@ public class SharePathServiceImpl implements SharePathService {
 | 
	
		
			
				|  |  |          return null;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public List<TreeNode> sharePathDO2TreeNode(List<SharePathDO> sharePathDOS) {
 | 
	
		
			
				|  |  | +        return sharePathDOS.stream().map(k -> TreeNode.builder()
 | 
	
		
			
				|  |  | +                .phone(k.getDescPhone())
 | 
	
		
			
				|  |  | +                .name(k.getDescName())
 | 
	
		
			
				|  |  | +                .deep(k.getDepth())
 | 
	
		
			
				|  |  | +                .parentId(k.getAncestor())
 | 
	
		
			
				|  |  | +                .userId(k.getDescendant())
 | 
	
		
			
				|  |  | +                .nickname(k.getDescNickName()).build()).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public static List<TreeNode> listWithTree(List<TreeNode> all, Long pid) {
 | 
	
		
			
				|  |  | +        // 2、找到一级父类,再通过级联去查询儿子
 | 
	
		
			
				|  |  | +        return all.stream().filter(k ->
 | 
	
		
			
				|  |  | +                k.getParentId().equals(pid)   //查询父类
 | 
	
		
			
				|  |  | +        ).map(k -> {
 | 
	
		
			
				|  |  | +            k.setChildren(getChildren(k, all));
 | 
	
		
			
				|  |  | +            return k;//查询子类菜单
 | 
	
		
			
				|  |  | +        }).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public static List<TreeNode> getChildren(TreeNode root, List<TreeNode> all) {
 | 
	
		
			
				|  |  | +        // 递归查找所有后代的儿子
 | 
	
		
			
				|  |  | +        return all.stream().filter(k -> k.getParentId().equals(root.getUserId()))
 | 
	
		
			
				|  |  | +                .map(k -> {
 | 
	
		
			
				|  |  | +                    k.setChildren(getChildren(k, all));
 | 
	
		
			
				|  |  | +                    return k;
 | 
	
		
			
				|  |  | +                }).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void transferenceRela(SharePathtransFerenceRelaReqVO sharePathtransFerenceRelaReqVO) {
 | 
	
		
			
				|  |  |          // todo 转让用户关系
 |