1 Star 0 Fork 842

gherkin/Mybatis_PageHelper

forked from abel533/Mybatis_PageHelper 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Page.java 2.45 KB
一键复制 编辑 原始数据 按行查看 历史
import org.apache.ibatis.session.RowBounds;
import java.util.ArrayList;
import java.util.List;
/**
* Description: 分页
* Author: liuzh
* Update: liuzh(2014-04-16 10:56)
* Update: liuzh(2014-05-21 20:07)
*/
public class Page<E> extends ArrayList<E> {
/**不进行count查询*/
public static final int NO_SQL_COUNT = -1;
public static final int SQL_COUNT = 0;
private int pageNum;
private int pageSize;
private int startRow;
private int endRow;
private long total;
private int pages;
public Page(int pageNum, int pageSize) {
this(pageNum, pageSize, SQL_COUNT);
}
public Page(int pageNum, int pageSize, int total) {
super(pageSize);
this.pageNum = pageNum;
this.pageSize = pageSize;
this.total = total;
this.startRow = pageNum > 0 ? (pageNum - 1) * pageSize : 0;
this.endRow = pageNum * pageSize;
}
public Page(RowBounds rowBounds){
super(rowBounds.getLimit());
this.pageSize = rowBounds.getLimit();
this.startRow = rowBounds.getOffset();
//RowBounds方式默认不求count总数,如果想求count,可以修改这里为SQL_COUNT
this.total = NO_SQL_COUNT;
this.endRow = this.startRow+this.pageSize;
}
public List<E> getResult() {
return this;
}
public int getPages() {
return pages;
}
public void setPages(int pages) {
this.pages = pages;
}
public int getEndRow() {
return endRow;
}
public void setEndRow(int endRow) {
this.endRow = endRow;
}
public int getPageNum() {
return pageNum;
}
public void setPageNum(int pageNum) {
this.pageNum = pageNum;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getStartRow() {
return startRow;
}
public void setStartRow(int startRow) {
this.startRow = startRow;
}
public long getTotal() {
return total;
}
public void setTotal(long total) {
this.total = total;
}
@Override
public String toString() {
return "Page{" +
"pageNum=" + pageNum +
", pageSize=" + pageSize +
", startRow=" + startRow +
", endRow=" + endRow +
", total=" + total +
", pages=" + pages +
'}';
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gherkin/Mybatis_PageHelper.git
[email protected]:gherkin/Mybatis_PageHelper.git
gherkin
Mybatis_PageHelper
Mybatis_PageHelper
master

搜索帮助