springboot整合PageHelper

1.pom文件中引入Pagehelper分頁插件

<!-- 分頁插件 -->
<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper-spring-boot-starter</artifactId>
    <version>1.2.5</version>
</dependency>

 

2.配置分頁插件

打開application.yml,添加以下幾行配置信息mysql

 

#分頁插件

pagehelper:
  helper-dialect: mysql
  params: count=countSql
  reasonable: true
  support-methods-arguments: true

 

 

3. 分頁樣例

public ReturnBean<List<T>> selectList(Map para) {
    Long count = getMapper().selectListCount(para);
    PageHelper.startPage(Integer.valueOf(para.get(SysConstant.PAGE).toString()),Integer.valueOf(para.get(SysConstant.LIMIT).toString()));
    List<T> list = getMapper().selectList(para);
    PageInfo<T> pageInfo = new PageInfo<T>(list);
    return ReturnBean.list(pageInfo.getList(),count);
}

結束git

相關文章
相關標籤/搜索