后台分页查询
一、分页
1、EduConfig中配置分页插件
/**
* 分页插件
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
2、分页Controller方法
EduTeacherController中添加分页方法
//3、分页查询讲师的方法
//current当前页,limit每页记录数
@ApiOperation(value = "分页查询讲师")
@GetMapping("pageTeacher/{current}/{limit}")
public R pageListTeacher(
@ApiParam(name = "current", value = "当前页", required = true)
@PathVariable long current,
@ApiParam(name = "limit", value = "每页记录数", required = true)
@PathVariable long limit) {
//创建page对象,1为当前页,3为每页的记录数
Page<EduTeacher> pageTeacher = new Page<>(current, limit);
//调用方法实现分页
//调用方式时候,底层封装,把所有数据封装到pageTeacher对象中
teacherService.page(pageTeacher, null);
//得到总记录数
long total = pageTeacher