部门查询子级递归调用

public List<SysDept> getTree(List<SysDept> list){
	List<SysDept> collect = list.stream().filter(m->m.getParentId() == 0).map(
		(m) ->{
			m.setChildren(getChildrens(m,list));
			return m;	
		}
	).collect(Collectors.toList());
}

private List<SysDept> getChildrens(SysDept root , List<SysDept> all){
	List<SysDept> children = all.stream().filter(m->{
		return Objects.equals(m.getParentId(),root.getDeptId());
	}).map(
		(m) -> {
			m.setChildren(getChildrens(m,all));
			return m;
		}
	).collect(Collectors.toList());
	return children;
}

你可能感兴趣的:(递归调用,java)