首页>代码>SpringBoot整合MyBatis实现记录孩子成长过程的博客系统>/babylog/src/main/java/net/vv2/Utils/PageHelp.java
package net.vv2.Utils;


import com.xiaoleilu.hutool.util.PageUtil;

/**
 * 简单分页工具
 * 返回总页数,并根据当前页值取得mysql limit 偏移量值
 * @author J.Sky bosichong@qq.com
 * @create 2017-06-13 11:16
 **/
public class PageHelp {


    /**
     * 总记录数
     */
    private int count;

    /**
     * 每页行数
     */
    private int rows =10;

    /**
     * 当前页数值 默认为1
     */
    private int pageNum = 1;






    public PageHelp() {
    }

    /**
     *
     * @param count 记录总数
     * @param pageNum 当前页码数
     * @param rows 每页显示的行数
     */
    public PageHelp(int count, int pageNum,int rows) {
        this.count = count;
        this.rows = rows;
        this.pageNum = pageNum;
    }

    public void setCount(int count) {
        this.count = count;
    }

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

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getCount() {
        return count;
    }

    public int getRows() {
        return rows;
    }

    public int getPageNum() {
        return pageNum;
    }

    /**
     * 获得翻页数据数组包括:
     * 分页数
     * mysql limit偏移量
     * @return int[]
     */
    public int[] getPageArray(){
        if(count == 0){
            return null;
        }
        int totalPage = PageUtil.totalPage(count,rows);//根据记录总数获得分页总数
        int offset = (pageNum-1)*rows;//获得当前偏移量。

        return new int[]{totalPage,offset};

    }
}
最近下载更多
kk992127170  LV6 2022年12月27日
tgeuuy  LV10 2022年10月25日
testuser1234567  LV24 2022年6月8日
zhos0212  LV19 2022年4月20日
zackery  LV9 2022年4月19日
fantesy  LV17 2022年3月3日
wang512237140  LV20 2021年12月21日
tansuo阿郎  LV8 2021年11月17日
尹恒yingying  LV18 2021年10月22日
huaua7676  LV30 2021年9月25日
最近浏览更多
梁小贤  LV1 5月22日
暂无贡献等级
ma406805131  LV19 2024年12月19日
citybird  LV4 2024年11月18日
栾庆浩 2024年10月29日
暂无贡献等级
小小ffggyh  LV1 2024年9月12日
嘻嘻不嘻嘻 2024年8月5日
暂无贡献等级
dapeng0011  LV15 2024年6月22日
f22m1a2b2  LV17 2024年6月8日
一只大笨熊啊 2024年6月8日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友