ソースを参照

更新 PageBound 分页类

reghao 2 年 前
コミット
d3fcdc6500
1 ファイル変更16 行追加0 行削除
  1. 16 0
      jdk/src/main/java/cn/reghao/jutil/jdk/db/PageBound.java

+ 16 - 0
jdk/src/main/java/cn/reghao/jutil/jdk/db/PageBound.java

@@ -43,4 +43,20 @@ public class PageBound {
 
         return new PageBound(start, end);
     }
+
+    public static PageBound get(int pageNumber, int pageSize, int total) {
+        if (total == 0) {
+            return new PageBound(0, 0);
+        }
+
+        int totalPages = total/pageSize;
+        int mod = total%pageSize;
+        if (mod != 0) {
+            totalPages += 1;
+        }
+
+        int start = (pageNumber-1)*pageSize;
+        int end = start + pageSize;
+        return new PageBound(start, end);
+    }
 }