public Page<StudentMessage> findInorderDetailByQuery(OrderVo vo) {
List<StuAndClass> sacs = this.classAndStuRepository.findByClassid(vo.getClassId());
if(!IsNotNullValit.CollectionIsNotNull(sacs)) {
return null;
}
Pageable pageable = PageRequest.of(vo.getPageNum()-1, vo.getPageSize(),Sort.by("createTime"));
Specification<StudentMessage> stu = new Specification<StudentMessage>() {
@Override
public Predicate toPredicate(Root<StudentMessage> root, CriteriaQuery<?> query,
CriteriaBuilder cb) {
Path<String> name = root.get("name");
Path<String> phone = root.get("phone");
Path<String> id = root.get("id");
Predicate p1 = cb.and(cb.like(name, "%"+vo.getName()+"%"));
Predicate p2 = cb.and(cb.like(phone, "%"+vo.getPhone()+"%"));
In<String> inc = cb.in(id);
for (StuAndClass sac : sacs) {
inc.value(sac.getStuid());
}
Predicate p3 = cb.and(inc);
return cb.and(p1,p2,p3);
}
};
return this.inorderRepository.findAll(stu,pageable);
}
jpa,复杂查询包括 like跟in,以及排序-----------------------gxy
最新推荐文章于 2024-07-29 11:02:40 发布