分页和条件查询接口开发

分页

MyBatisPlusConfig中配置分页插件

/**
 * 分页插件
 */
@Bean
public PaginationInterceptor paginationInterceptor() {
    return new PaginationInterceptor();
}

分页Controller方法

TeacherAdminController中添加分页方法

@ApiOperation(value = "分页讲师列表")
@GetMapping("{page}/{limit}")
public R pageList(
    @ApiParam(name = "page", value = "当前页码", required = true)
    @PathVariable Long page,

    @ApiParam(name = "limit", value = "每页记录数", required = true)
    @PathVariable Long limit){

    Page pageParam = new Page<>(page, limit);

    teacherService.page(pageParam, null);
    List records = pageParam.getRecords();
    long total = pageParam.getTotal();

    return  R.ok().data("total", total).data("rows", records);
}

 

你可能感兴趣的:(分页和条件查询接口开发)