page分页类

package cn.kgc.keyword.uitl;
/**
 * todo 分页类
 * todo @author Administrator
 * 页码,页容量,总条数,总页数,数据集合
 * 页码:有前端指定
 * 页容量:由前段指定
 * 总条数:根据符合条件的数据库数据数量来决定
 * 总页数:总条数/页容量 (+1)
 * 数据集合:当前符合所有数据的集合
 * 查询数据的起始位置:(页码-1)*页容量
 */
public class PageUtil<T> {
    /**
     * 页码
     */
    private Integer pageIndex;
    /**
     * 页容量
     */
    private Integer pageSize;
    /**
     * 总条数
     */
    private Integer total;
    /**
     * 总页数
     */
    private Integer totalPage;
    /**
     * 数据的集合
     */
    private T rows;
    /**
     * 起始位置
     */
    private Integer beginIndex;

    /**
     *  PageUtil构造方法,用来得到页码,页容量,总条数,总页数,起始位置
     * @param pageIndex 用来得到页码
     * @param pageSize 页容量
     * @param total 总条数
     *  totalPage 总页数
     */
    public PageUtil(Integer pageIndex, Integer pageSize, Integer total){
        this.pageIndex=pageIndex;
        this.pageSize=pageSize;
        this.total=total;
        /**todo ?前为ture,返回 : 前面的,为false 返回 :后面的*/
        this.totalPage=total % pageSize==0 ?total / pageSize:total /pageSize +1;
        this.beginIndex=(pageIndex-1)*pageSize;
    }

    public Integer getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(Integer pageIndex) {
        this.pageIndex = pageIndex;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public Integer getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public T getRows() {
        return rows;
    }

    public void setRows(T rows) {
        this.rows = rows;
    }

    public Integer getBeginIndex() {
        return beginIndex;
    }

    public void setBeginIndex(Integer beginIndex) {
        this.beginIndex = beginIndex;
    }
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值