diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/paginate/Page.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/paginate/Page.java index f89f7b7e..8b4e75d2 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/paginate/Page.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/paginate/Page.java @@ -24,7 +24,7 @@ import java.util.function.Function; public class Page implements Serializable { private static final long serialVersionUID = 1L; - private static final int INIT_VALUE = -1; + public static final int INIT_VALUE = -1; private List records = Collections.emptyList(); private int pageNumber = INIT_VALUE; @@ -112,9 +112,6 @@ public class Page implements Serializable { } public void setTotalRow(long totalRow) { - if (totalRow < 0) { - throw new IllegalArgumentException("totalRow must greater than or equal 0,current value is: " + totalRow); - } this.totalRow = totalRow; this.calcTotalPage(); } @@ -123,7 +120,9 @@ public class Page implements Serializable { * 计算总页码 */ private void calcTotalPage() { - if (totalPage == INIT_VALUE && pageSize != INIT_VALUE && totalRow != INIT_VALUE) { + if (pageSize < 0 || totalRow < 0) { + totalPage = INIT_VALUE; + } else { totalPage = totalRow % pageSize == 0 ? (totalRow / pageSize) : (totalRow / pageSize + 1); } }