Mybatis-plus中QueryWrapper的使用

时间:2025-04-06 20:29:06
//Controller @GetMapping("/listAndClass") public TableDataInfo listAndClass(Student student) { QueryWrapper<Student > qw = new QueryWrapper<Student >(); if(StringUtils.isNotBlank(student.getName())){ qw.eq("",student.getName()); } if(StringUtils.isNotBlank(student.getClassName())){ qw.like("",student.getClassName()); } startPage(); List<Student > list = studentService.listAndClass(qw); return getDataTable(list); } //Service List<Student> listAndClass(QueryWrapper<Student> qw); //Service impl @Override public List<Student> listAndClass(QueryWrapper<Student> qw) { return this.getBaseMapper().listAndClass(qw); } //Mapper @Select("select s.*, from student s left join class c on = c.student_id "+ "${}") List<YwSpaqjgDj> listAndClass(@Param(Constants.WRAPPER) QueryWrapper<Student> qw);