2021-11-01

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();
}

上一篇:[原创]java WEB学习笔记51:国际化 概述,API 之 locale类,dataFormat类,numberFormat类, MessageFormat类,ResourceBundle 类


下一篇:Java NIO 学习笔记(一)----概述,Channel/Buffer