Java中递归树形菜单模块代码

 private void getNodeForSysDept(List<SysDept> deptList, Node node, int type,  SysPermission sysPermission, List<Node> nodes,String str) {
  String pid = node.getId();
  for (SysDept sysDept:deptList) {
   node = new Node();
   List<SysDept> ls = sysDept.getChildrenDept();
   if(ls.size()==0){
    List<SysPermission> sysPermissionList = new ArrayList<SysPermission>();
    sysPermissionList =  sysPermissionDao.findListByFatherId(sysPermission.getId());
    if(sysPermissionList.size()>=1){
     str = sysPermissionList.get(0).getUrl();
     node.setUri(str);
    }
   }
   node.setId(type+"_"+sysDept.getId().toString());
   node.setName(sysDept.getDeptName());      
   node.setPid(pid);
   
   if (ls.size()>0) {
    getNodeForSysDept(ls, node, type, sysPermission,nodes,str);
   }
   
   nodes.add(node);
  }
  
 }

你可能感兴趣的:(递归部门树形菜单)