PageHelper分页
引入依赖
<!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.13</version>
</dependency>
开启查询 自动分页 返回总count和查询数据即可
PageHelper.startPage(pageNum, pageSize);
List<XfSipgApplyPO> applyPOList = applyMapper.selectByCompanyName(companyName, startDate, endDate);
PageInfo<XfSipgApplyPO> pageResult = new PageInfo<>(applyPOList);
return new PageResult(voList, pageResult.getTotal());
查询返回结果
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(description = "分页返回结果")
public class PageResult {
@ApiModelProperty(value = "查询结果")
private Object data;
@ApiModelProperty(value = "总数量")
private Long totalCount;
}
yaml文件中加入下面
pagehelper:
helper-dialect: mysql
reasonable: false
support-methods-arguments: true