标准分页组件,基于springboot的开发变得相当简单:
1、maven引入依赖
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.5</version>
</dependency>
2、在调用DAO层前设置分页参数,并使用PageInfo对象包装结果
PageHelper.startPage(pageNum, pageSize, orderBy);
List<Detail> details = mapper.find(id,type, market, code);
PageInfo<Detail> results = new PageInfo<Detail>(details);
3、返回样例
{
"total": 12274,
"list": [{
"name": "xx",
"id": "idxxx",
"securities": [{
"type": "xxtype",
"market": "sh",
"name": "namexxx",
"code": "codexxx",
"operater": "",
"operateDate": "",
"auditStatus": ""
}, {
"type": "yytype",
"market": "sh",
"name": "nameyy",
"code": "codeyy",
"operater": "",
"operateDate": "",
"auditStatus": ""
}]
}],
"pageNum": 1,
"pageSize": 2,
"size": 1,
"startRow": 1,
"endRow": 1,
"pages": 6137,
"prePage": 0,
"nextPage": 2,
"isFirstPage": true,
"isLastPage": false,
"hasPreviousPage": false,
"hasNextPage": true,
"navigatePages": 8,
"navigatepageNums": [1, 2, 3, 4, 5, 6, 7, 8],
"navigateFirstPage": 1,
"navigateLastPage": 8,
"firstPage": 1,
"lastPage": 8
}
网友评论