浏览代码

fixed 121

jobob 8 年之前
父节点
当前提交
45bfa361ba

+ 8 - 5
mybatis-plus/src/main/java/com/baomidou/mybatisplus/plugins/pagination/Pagination.java

@@ -121,10 +121,6 @@ public class Pagination extends RowBounds implements Serializable {
 
 	public void setTotal(int total) {
 		this.total = total;
-		this.pages = this.total / this.size;
-		if (this.total % this.size != 0) {
-			this.pages++;
-		}
 	}
 
 	public int getSize() {
@@ -136,7 +132,14 @@ public class Pagination extends RowBounds implements Serializable {
 	}
 
 	public int getPages() {
-		return pages;
+		if (this.size == 0) {
+			return 0;
+		}
+		this.pages = this.total / this.size;
+		if (this.total % this.size != 0) {
+			this.pages++;
+		}
+		return this.pages;
 	}
 
 	public void setCurrent(int current) {