修改部分bug

master
星期八 5 years ago
parent 105a8ac307
commit 35b51712e5
  1. 38
      panda-code/src/main/java/org/panda/code/uitl/CollectionUtil.java

@ -63,25 +63,31 @@ public class CollectionUtil {
public static <T> List<T> subPageList(List<T> list,int page,int pageSize){
List<T> pageList = new ArrayList(pageSize);
//list不为NULL而且list的size>0
if (list!=null&&list.size()>0&&page>0&&pageSize>0) {
//总页数
int count = list.size();
int pageCount = count / pageSize;
if ((pageCount % pageSize) != 0) {
pageCount++;
}
if (page <= pageCount) {
//开始索引
int startIndex;
//结束索引
int endIndex;
endIndex = (page * pageSize) - 1;
startIndex = endIndex - pageSize;
pageList = pageList.subList(startIndex, endIndex);
if (list!=null) {
if (list.size()>0&&page>0&&pageSize>0) {
//总页数
int count = list.size();
int pageCount = count / pageSize;
if ((pageCount % pageSize) != 0) {
pageCount++;
}
if (page <= pageCount) {
//开始索引
int startIndex;
//结束索引
int endIndex;
endIndex = (page * pageSize);
startIndex = endIndex - pageSize;
if (startIndex < 0) {
startIndex = 0;
}
pageList = list.subList(startIndex, endIndex);
}
}else {
pageList.addAll(list);
}
}
return pageList;
}
}

Loading…
Cancel
Save