mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-09-09 08:57:17 +08:00
@@ -93,12 +93,10 @@ public class PageResp<L> extends BasePageResp<L> {
|
|||||||
pageResp.setTotal(list.size());
|
pageResp.setTotal(list.size());
|
||||||
// 对列表数据进行分页
|
// 对列表数据进行分页
|
||||||
int fromIndex = (page - 1) * size;
|
int fromIndex = (page - 1) * size;
|
||||||
int toIndex = page * size + fromIndex;
|
if (fromIndex >= list.size()) {
|
||||||
if (fromIndex > list.size()) {
|
|
||||||
pageResp.setList(new ArrayList<>(0));
|
pageResp.setList(new ArrayList<>(0));
|
||||||
} else if (toIndex >= list.size()) {
|
|
||||||
pageResp.setList(list.subList(fromIndex, list.size()));
|
|
||||||
} else {
|
} else {
|
||||||
|
int toIndex = Math.min(fromIndex + size, list.size());
|
||||||
pageResp.setList(list.subList(fromIndex, toIndex));
|
pageResp.setList(list.subList(fromIndex, toIndex));
|
||||||
}
|
}
|
||||||
return pageResp;
|
return pageResp;
|
||||||
|
@@ -93,12 +93,10 @@ public class PageResp<L> extends BasePageResp<L> {
|
|||||||
pageResp.setTotal(list.size());
|
pageResp.setTotal(list.size());
|
||||||
// 对列表数据进行分页
|
// 对列表数据进行分页
|
||||||
int fromIndex = (page - 1) * size;
|
int fromIndex = (page - 1) * size;
|
||||||
int toIndex = page * size + fromIndex;
|
if (fromIndex >= list.size()) {
|
||||||
if (fromIndex > list.size()) {
|
|
||||||
pageResp.setList(new ArrayList<>(0));
|
pageResp.setList(new ArrayList<>(0));
|
||||||
} else if (toIndex >= list.size()) {
|
|
||||||
pageResp.setList(list.subList(fromIndex, list.size()));
|
|
||||||
} else {
|
} else {
|
||||||
|
int toIndex = Math.min(fromIndex + size, list.size());
|
||||||
pageResp.setList(list.subList(fromIndex, toIndex));
|
pageResp.setList(list.subList(fromIndex, toIndex));
|
||||||
}
|
}
|
||||||
return pageResp;
|
return pageResp;
|
||||||
|
Reference in New Issue
Block a user