Commit 59a9bf1f1a35a8a35a728ebb46650bc4c3a5c296
1 parent
7b7da9dd57
Exists in
master
and in
6 other branches
分页bug修复
Showing 1 changed file with 6 additions and 3 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/CollectionUtils.java
View file @
59a9bf1
... | ... | @@ -162,10 +162,13 @@ |
162 | 162 | public static <T> List<T> getPageIds(List<T> data, Integer page, Integer limit) { |
163 | 163 | Integer startIndex = (page - 1) * limit; |
164 | 164 | Integer endIndex = startIndex + limit; |
165 | - if(data.size() > endIndex) { | |
166 | - return data.subList(startIndex, endIndex); | |
165 | + if(startIndex >= data.size()) { | |
166 | + return new ArrayList<>(); | |
167 | 167 | } |
168 | - return data.subList(startIndex, data.size()); | |
168 | + if(endIndex > data.size() - 1) { | |
169 | + return data.subList(startIndex, data.size() - 1); | |
170 | + } | |
171 | + return data.subList(startIndex, endIndex); | |
169 | 172 | } |
170 | 173 | |
171 | 174 | } |