부서 트리 반복 조회

2165 단어 java 기술
    /**
     *  
     *
     * @return
     */
    @ResponseBody
    @RequestMapping("/findOrgTree")
    public SystemResult findOrgTree(long companyId) {
        log.info(" companyId={}", companyId);
        // id , 
        SysCompanyEntity sysCompany = pcSysCompanyDao.getOne(companyId);
        SysOrganizationEntity sysOrg = new SysOrganizationEntity();
        sysOrg.setName(sysCompany.getName());
        sysOrg.setId(-1);
        SysOrganizationTree sysOrganizationTree = new SysOrganizationTree();
        sysOrganizationTree.setSysOrganization(sysOrg);
        // id -1
        long pId = -1;
        SysOrganizationTree sysOrgTree = getOrgTreeByPid(sysOrganizationTree, pId, companyId);
        result = new SystemResult(Dict_transaction_result_code.SUCCESS, " ", sysOrgTree);
        log.info(" result={}", JSONObject.toJSONString(result));
        return result;
    }

    /**
     *  List- 
     *
     * @param sysOrganizationTree
     * @param pId                  id
     */
    private SysOrganizationTree getOrgTreeByPid(SysOrganizationTree sysOrganizationTree, long pId, long sysCoPid) {
        // Id list
        List sysOrganizationList = pcSysOrganizationDao.findListByPIdAndSysCoPid(pId, sysCoPid);


        if (sysOrganizationList != null) {
            List SysOrganizationTreeList = new ArrayList();
            for (SysOrganizationEntity sysOrganizationEntity :
                    sysOrganizationList) {
                SysOrganizationTree sysOrganizationTreeSon = new SysOrganizationTree();
                sysOrganizationTreeSon.setSysOrganization(sysOrganizationEntity);
                // 
                SysOrganizationTree orgTreeByPid = getOrgTreeByPid(sysOrganizationTreeSon, sysOrganizationEntity.getId(), sysCoPid);
                SysOrganizationTreeList.add(orgTreeByPid);
            }
            sysOrganizationTree.setSysOrganizationTreeList(SysOrganizationTreeList);
        }
        return sysOrganizationTree;
    }

좋은 웹페이지 즐겨찾기