/**
* for shanshan
* @param depId
* @return
*/
public List sonDepsHelei(Long depId){
//查询所有部门
List list = deptRepository.findAll();
//1 List 需要有范型
List allChildIdList = Lists.newArrayList();
//2 需要把 结果的list ,当作参数传递到方法里,你之前的写法,只能返回第一层的数据,做不到递归
getChildIdHelei(allChildIdList,depId,list);
allChildIdList.add(depId);
return allChildIdList;
}
public void getChildIdHelei(List<Long> rs,Long parentId,List<DeptDO> deptList){
for(DeptDO depdo:deptList){
if(depdo.getParentId().equals(parentId)){
rs.add(depdo.getDeptId());
getChildIdHelei(rs,depdo.getDeptId(), deptList);
}
}
}