MyBatis-Plus封装分页
分页工具类
@Data
public class PageResult<T> {
/**
* 数据总数
*/
private long count;
/**
* 数据记录
*/
private List<T> records;
/***
* 总页数
*/
private long pages;
public PageResult(IPage<T> page) {
this.count = page.getTotal();
this.records = page.getRecords();
this.pages = count % page.getSize() == 0 ? count / page.getSize() : count / page.getSize() + 1;
}
/**
* 分页封装到这里
* @param list
* @param count
*/
public PageResult(List<T> list, Long count, long size) {
this.count = count;
this.records = list;
this.pages = count % size == 0 ? count / size : count / size + 1;
}
}
service层:
/**
* 分页查询所有项目
*
* @param page 分页
* @param orderState 项目状态
* @param condition 项目名称模糊查询
* @return
*/
PageResult orderPageList(Page page, Integer orderState, String condition);
serviceImpl层(第一种分页方法):
@Override
public PageResult orderPageList(