PageInfo getPageInfo(int pageNum, int pageSize, List<Map> list) {
Page page = new Page(pageNum, pageSize);
int total = list.size();
if (total > pageSize) {
int toIndex = pageNum * pageSize;
int startIndex = (pageNum - 1) * pageSize;
if (toIndex > total) {
toIndex = total;//结尾index
}
page.addAll(list.subList(startIndex, toIndex));
}
page.setPages((total - 1) / pageSize + 1);//总共有多少页
page.setTotal(total);
PageInfo pageInfo = new PageInfo(page);
return pageInfo;
}