public List buildTree(List jiGouList, Integer shangJiId) {
List children = new ArrayList<>();
for (Dept dept : jiGouList) {
if (shangJiId.equals(dept.getShangJiId())){
children.add(dept);
dept.setChildren(buildTree(jiGouList, dept.getId()));
}
}
return children;
}
树形结构 上级id 本身id 本身的名称
查询条件
public Predicate getPredicate(Root r, CriteriaQuery<?> q, CriteriaBuilder cb, DeptQuery query){
Predicate p = r.get(“id”).isNotNull();
if(StringUtils.isNotEmpty(query.getOrganize())){
p = cb.and(p,cb.like(r.get(“organize”),"%"+query.getOrganize()+"%"));
}
q.where(cb.and§);
q.orderBy(cb.desc(r.get(“id”)));
return q.getRestriction();
}