1.分页带条件查询

  1. /**
  2. * 分页带条件查询老师信息
  3. * @param pageNo
  4. * @param o
  5. * @return
  6. */
  7. public PageInfo teacherPage(int pageNo, Teacher o) {
  8. PageHelper.startPage(pageNo, Sys.pageSize,"id desc");
  9. LambdaQueryWrapper<Teacher> lambdaQueryWrapper = Wrappers.lambdaQuery();
  10. //条件查询
  11. if (Objects.nonNull(o.getRealName()) && o.getRealName().trim().length()>0) {
  12. lambdaQueryWrapper.like(Teacher ::getRealName, o.getRealName());
  13. }
  14. if (Objects.nonNull(o.getState())) {
  15. lambdaQueryWrapper.eq(Teacher ::getState, o.getState());
  16. }
  17. if (Objects.nonNull(o.getTeaNo()) && o.getTeaNo().trim().length()>0) {
  18. lambdaQueryWrapper.eq(Teacher ::getTeaNo, o.getTeaNo());
  19. }
  20. List<Teacher> li = teacherDao.selectList(lambdaQueryWrapper);
  21. PageInfo<Teacher> pageInfo=new PageInfo(li,Sys.pageSize);
  22. return pageInfo;
  23. }

2.不分页排序

  1. lambdaQueryWrapper.orderByDesc(StoreConsumer::getRegisterTime);

3.springboot整合mybatisPlus