Explorar o código

page 提供静态构造方式

hubin %!s(int64=4) %!d(string=hai) anos
pai
achega
7f8ce0495c

+ 17 - 0
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/pagination/Page.java

@@ -273,4 +273,21 @@ public class Page<T> implements IPage<T> {
         // 解决 github issues/3208
         return IPage.super.getPages();
     }
+
+    /* --------------- 以下为静态构造方式 --------------- */
+    public static <T> Page<T> of(long current, long size) {
+        return of(current, size, 0);
+    }
+
+    public static <T> Page<T> of(long current, long size, long total) {
+        return of(current, size, total, true);
+    }
+
+    public static <T> Page<T> of(long current, long size, boolean isSearchCount) {
+        return of(current, size, 0, isSearchCount);
+    }
+
+    public static <T> Page<T> of(long current, long size, long total, boolean isSearchCount) {
+        return new Page(current, size, total, isSearchCount);
+    }
 }