业务代码如下:
public PageBean<CompanyDTO> getCompanyList( int pageIndex, int pageSize, CompanyDTO companyDTO) {
PageHelper.startPage(pageIndex, pageSize);
int counts = this.countCompanyByCond(companyDTO);
List<CompanyDTO> companyDTOS = companyDTOMapper.getCompanyListByCond(companyDTO);
PageBean companyPage = new PageBean<>(pageIndex, pageSize, counts);
companyPage.setItems(companyDTOS);
return companyPage;
}
用的是pagehelper-spring-boot-starter
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.3</version>
</dependency>
// 配置文件
pagehelper:
helperDialect: mysql
reasonable: true
supportMethodsArguments: true
params: count=countSql
但是分页就是不生效,每次都会查出全量数据