集合递归demo
private List<Dept> getChildList(List<Dept> list ,Integer parentId){ List<Dept> resList = new ArrayList(); for(Dept dept : list){ if(dept.getParentId() != null && dept.getParentId().intValue()== parentId.intValue()){ List<Dept> childList = getChildList(list,dept.getId()); dept.setChildren(childList); resList.add(dept); } } return resList; }