美文网首页
递归调用获取所有父子节点数据

递归调用获取所有父子节点数据

作者: ml66 | 来源:发表于2019-06-26 10:32 被阅读0次
        @RequestMapping("/zhiwei")
        @ResponseBody
        public Result orgChart(Model model,String orgId){
            try {
                //查询最高级别的职务
                List<OrganizationStructure> dutys = orgService.getStructureDutysForParentIsNull(orgId);
                List<OrganizationStructure> dutyLists=new ArrayList<OrganizationStructure>();
                return Result.success( getChild(dutys,dutyLists));
            } catch (Exception e) {
                e.printStackTrace();
                return Result.failed(e.getMessage());
            }
        }
     public List<OrganizationStructure> getChild(List<OrganizationStructure> dutys,List<OrganizationStructure> dutyLists){
    
            if (CollectionUtils.isEmpty(dutys)) {
    
            }else{
                for (OrganizationStructure orgStructure : dutys){
                    String imgPathProfix = ConstantUtil.OSS_FILE_PATH;
                    String defaultImgPath = "";
                    String imgPath= attachmentDetaillService.getByResourceId(orgStructure.getUserId()).getAttachURL();
                    orgStructure.setUserImgUrl(StringUtils.isBlank(imgPath) ? defaultImgPath : imgPathProfix + imgPath);
                    dutyLists.add(orgStructure);
                    List<OrganizationStructure> childDutyLists = orgService.getStructureDutysForDutyParentId(orgStructure.getDutyId());
                    getChild(childDutyLists,dutyLists);
                }
            }
            return dutyLists;
        }
    

    相关文章

      网友评论

          本文标题:递归调用获取所有父子节点数据

          本文链接:https://www.haomeiwen.com/subject/ytvqcctx.html