/***
 * 分页工具类
 */
public class Page {
    
    private int pageSize = 5;// 页显示条数
    private int currentPage;// 当前页码
    private Long totalSize;// 总记录条数
    private int totalPage;// 总页数
    private int beginSize;// 开始查询记录条数
    private int endSize;// 结束查询记录条数
    private List<Map<String, Object>> list;// 记录
    
    public Page(int currentPage){
        this.currentPage = currentPage;
    }
    
    public int getPageSize() {
        return pageSize;
    }
    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
    public int getCurrentPage() {
        return currentPage;
    }
    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }
    public Long getTotalSize() {
        return totalSize;
    }
    public void setTotalSize(Long totalSize) {
        this.totalSize = totalSize;
    }
    public int getTotalPage() {
        Long totalSize = getTotalSize();
        return (int) (totalSize%pageSize==0?(totalSize/pageSize):(totalSize/pageSize+1));
    }
    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }
    public List<Map<String, Object>> getList() {
        return list;
    }
    public void setList(List<Map<String, Object>> list) {
        this.list = list;
    }
    public int getBeginSize() {
        return beginSize = currentPage>0?(currentPage-1) * pageSize + 1:0;
    }
    public void setBeginSize(int beginSize) {
        this.beginSize = beginSize;
    }
    public int getEndSize() {
        int beginSize = getBeginSize();
        return beginSize + pageSize - (beginSize>0?1:0);
    }
    public void setEndSize(int endSize) {
        this.endSize = endSize;
    }
    
}

 

posted on 2018-10-12 16:55  沛昕的博客  阅读(249)  评论(0编辑  收藏  举报