mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
添加分页时每页显示的数据数量最大限制
This commit is contained in:
parent
39aa24872f
commit
cdbc91f427
@ -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;
|
||||
}
|
||||
|
||||
@ -51,6 +51,11 @@ public class Page<T> implements Serializable {
|
||||
*/
|
||||
private long pageSize = FlexGlobalConfig.getDefaultConfig().getDefaultPageSize();
|
||||
|
||||
/**
|
||||
* 每页数据数量最大限制。
|
||||
*/
|
||||
private long maxPageSize = FlexGlobalConfig.getDefaultConfig().getDefaultMaxPageSize();
|
||||
|
||||
/**
|
||||
* 总页数。
|
||||
*/
|
||||
@ -196,7 +201,7 @@ public class Page<T> 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();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user