From d96a5024f72b307686d4c76d06b040e97900d6fc Mon Sep 17 00:00:00 2001 From: qi Date: Tue, 17 Dec 2019 15:38:27 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=BF=BD=E7=95=A5=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index cd09efa..faf8c97 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ # Created by .ignore support plugin (hsz.mobi) *.iml +*.*.iml .idea From f9cd5a10f9856d4458655430d0f8ae5766e03eea Mon Sep 17 00:00:00 2001 From: qi Date: Fri, 6 Mar 2020 16:28:25 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0list=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E5=B0=8F=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/panda/code/uitl/CollectionUtil.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/panda-code/src/main/java/org/panda/code/uitl/CollectionUtil.java b/panda-code/src/main/java/org/panda/code/uitl/CollectionUtil.java index 7ff7d1e..ec6076c 100644 --- a/panda-code/src/main/java/org/panda/code/uitl/CollectionUtil.java +++ b/panda-code/src/main/java/org/panda/code/uitl/CollectionUtil.java @@ -3,7 +3,9 @@ package org.panda.code.uitl; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; +import java.util.ArrayList; import java.util.Collection; +import java.util.List; import java.util.Map; /** @@ -50,4 +52,36 @@ public class CollectionUtil { public static boolean isNotEmpty(Map map){ return !isEmpty(map); } + + /** + * list分页 + * @param list + * @param page + * @param pageSize + * @return + */ + public static List subPageList(List list,int page,int pageSize){ + List 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); + } + } + return pageList; + } + + } From 35b51712e5ef001cad27cbe0c502ba73a5172354 Mon Sep 17 00:00:00 2001 From: qi Date: Fri, 6 Mar 2020 16:48:46 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=83=A8=E5=88=86bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/panda/code/uitl/CollectionUtil.java | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/panda-code/src/main/java/org/panda/code/uitl/CollectionUtil.java b/panda-code/src/main/java/org/panda/code/uitl/CollectionUtil.java index ec6076c..5356344 100644 --- a/panda-code/src/main/java/org/panda/code/uitl/CollectionUtil.java +++ b/panda-code/src/main/java/org/panda/code/uitl/CollectionUtil.java @@ -63,25 +63,31 @@ public class CollectionUtil { public static List subPageList(List list,int page,int pageSize){ List 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; } - }