手动写一个分页
collect为最终查到的所有结果的集合,pageNum和PageSize为分页条件
if (collect == null) {
return null;
}
if (collect.size() == 0) {
return collect;
}
Integer count = collect.size(); // 记录总数
Integer pageCount = 0; // 页数
if (count % pageSize == 0) {
pageCount = count / pageSize;
} else {
pageCount = count / pageSize + 1;
}
int fromIndex = 0; // 开始索引
int toIndex = 0; // 结束索引
if (pageNum != pageCount.intValue()) {
fromIndex = (pageNum - 1) * pageSize;
toIndex = fromIndex + pageSize;
} else {
fromIndex = (pageNum - 1) * pageSize;
toIndex = count;
}
List<WaitDealtVo> pageList = (List) collect.stream().skip(fromIndex).limit(pageSize).collect(Collectors.toList());
得到的结果就是已经分页过得