소스 검색

page 提供静态构造方式

hubin 4 년 전
부모
커밋
7f8ce0495c
1개의 변경된 파일17개의 추가작업 그리고 0개의 파일을 삭제
  1. 17 0
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/pagination/Page.java

+ 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);
+    }
 }