فهرست منبع

升级 spring boot 2.0.1

hubin 7 سال پیش
والد
کامیت
bf9caa3bf6
2فایلهای تغییر یافته به همراه16 افزوده شده و 16 حذف شده
  1. 1 1
      build.gradle
  2. 15 15
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/pagination/Pagination.java

+ 1 - 1
build.gradle

@@ -7,7 +7,7 @@ ext {
         mybatisSpringVersion = '1.3.2',
         mybatisVersion = '3.4.6',
         springVersion = '4.3.5.RELEASE',
-        springBootVersion = '1.5.9.RELEASE',
+        springBootVersion = '2.0.1.RELEASE',
     ]
 
     dependencies = [

+ 15 - 15
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/pagination/Pagination.java

@@ -42,18 +42,13 @@ public class Pagination extends RowBounds implements Serializable {
     /**
      * 总数
      */
-    private int total;
+    private long total;
 
     /**
      * 每页显示条数,默认 10
      */
     private int size = 10;
 
-    /**
-     * 总页数
-     */
-    private int pages;
-
     /**
      * 当前页
      */
@@ -146,14 +141,14 @@ public class Pagination extends RowBounds implements Serializable {
     }
 
     public boolean hasNext() {
-        return this.current < this.pages;
+        return this.current < this.getPages();
     }
 
-    public int getTotal() {
+    public long getTotal() {
         return total;
     }
 
-    public Pagination setTotal(int total) {
+    public Pagination setTotal(long total) {
         this.total = total;
         return this;
     }
@@ -167,15 +162,19 @@ public class Pagination extends RowBounds implements Serializable {
         return this;
     }
 
-    public int getPages() {
+    /**
+     * 总页数
+     * fixed github /issues/309
+     */
+    public long getPages() {
         if (this.size == 0) {
-            return 0;
+            return 0L;
         }
-        this.pages = this.total / this.size;
+        long pages = this.total / this.size;
         if (this.total % this.size != 0) {
-            this.pages++;
+            pages++;
         }
-        return this.pages;
+        return pages;
     }
 
     public int getCurrent() {
@@ -302,7 +301,8 @@ public class Pagination extends RowBounds implements Serializable {
 
     @Override
     public String toString() {
-        return "Pagination { total=" + total + " ,size=" + size + " ,pages=" + pages + " ,current=" + current + " }";
+        return "Pagination { total=" + total + " ,size=" + size + " ,pages=" + this.getPages() + " ,current=" + current + " }";
     }
 
 }
+