From cdbc91f427c1281b37a17bd46b3701ba007e7235 Mon Sep 17 00:00:00 2001 From: Leo <8571049+leoluo0818@users.noreply.github.com> Date: Sun, 21 Jul 2024 15:57:54 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=86=E9=A1=B5=E6=97=B6?= =?UTF-8?q?=E6=AF=8F=E9=A1=B5=E6=98=BE=E7=A4=BA=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E6=9C=80=E5=A4=A7=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/mybatisflex/core/FlexGlobalConfig.java | 13 +++++++++++++ .../java/com/mybatisflex/core/paginate/Page.java | 7 ++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/FlexGlobalConfig.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/FlexGlobalConfig.java index 4f4d8c43..6fd0c111 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/FlexGlobalConfig.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/FlexGlobalConfig.java @@ -83,6 +83,11 @@ public class FlexGlobalConfig { */ private int defaultPageSize = 10; + /** + * 分页查询时,默认每页显示的数据数量最大限制。 + */ + private int defaultMaxPageSize = Long.MAX_VALUE; + /** * 默认的 Relation 注解查询深度 @@ -278,6 +283,14 @@ public class FlexGlobalConfig { this.defaultPageSize = defaultPageSize; } + public int getDefaultMaxPageSize() { + return defaultMaxPageSize; + } + + public void setDefaultMaxPageSize(int defaultMaxPageSize) { + this.defaultMaxPageSize = defaultMaxPageSize; + } + public int getDefaultRelationQueryDepth() { return defaultRelationQueryDepth; } 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 0af90fa6..1ab8bb93 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 @@ -51,6 +51,11 @@ public class Page implements Serializable { */ private long pageSize = FlexGlobalConfig.getDefaultConfig().getDefaultPageSize(); + /** + * 每页数据数量最大限制。 + */ + private long maxPageSize = FlexGlobalConfig.getDefaultConfig().getDefaultMaxPageSize(); + /** * 总页数。 */ @@ -196,7 +201,7 @@ public class Page implements Serializable { if (pageSize <= 0) { throw new IllegalArgumentException("pageSize must greater than 0,current value is: " + pageSize); } - this.pageSize = pageSize; + this.pageSize = Math.min(pageSize, maxPageSize); this.calcTotalPage(); }