关于分页记录

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package cn.microvideo.framework.core.page;

public class MicrovideoPage {
    private int totalPages;
    private int pageSize = 10;
    private int firstPage;
    private int lastPage;
    private int currentPage;
    private int totalNum;
    private int startRow;
    private int endRow;

    public MicrovideoPage() {
    }

    public MicrovideoPage(int totalNum, int currentPage, int pageSize) {
        if (currentPage <= 0) {
            currentPage = 1;
        }

        if (pageSize <= 0) {
            pageSize = 10;
        }

        this.pageSize = pageSize;
        this.totalNum = totalNum;
        this.firstPage = totalNum > 0 ? 1 : 0;
        this.totalPages = totalNum % pageSize == 0 ? totalNum / pageSize : totalNum / pageSize + 1;
        this.lastPage = this.totalPages;
        this.currentPage = currentPage >= this.totalPages ? this.totalPages : currentPage;
        this.currentPage = currentPage <= this.firstPage ? this.firstPage : currentPage;
        this.startRow = currentPage == 0 ? 0 : (currentPage - 1) * pageSize;
        this.endRow = currentPage == this.getLastPage() ? this.getTotalNum() : currentPage * pageSize;
        this.startRow = this.startRow < 0 ? 0 : this.startRow;
        this.endRow = this.endRow < 0 ? 0 : this.endRow;
    }

    public MicrovideoPage(int totalNum, int currentPage) {
        if (currentPage <= 0) {
            currentPage = 1;
        }

        this.totalNum = totalNum;
        this.firstPage = totalNum > 0 ? 1 : 0;
        this.totalPages = totalNum % this.pageSize == 0 ? totalNum / this.pageSize : totalNum / this.pageSize + 1;
        this.lastPage = this.totalPages;
        this.currentPage = currentPage >= this.totalPages ? this.totalPages : currentPage;
        this.currentPage = currentPage <= this.firstPage ? this.firstPage : currentPage;
        this.startRow = currentPage == 0 ? 0 : (currentPage - 1) * this.pageSize;
        this.endRow = currentPage == this.getLastPage() ? this.getTotalNum() : currentPage * this.pageSize;
        this.startRow = this.startRow < 0 ? 0 : this.startRow;
        this.endRow = this.endRow < 0 ? 0 : this.endRow;
    }

    public int getTotalPages() {
        return this.totalPages;
    }

    public int getPageSize() {
        return this.pageSize;
    }

    public int getFirstPage() {
        return this.firstPage;
    }

    public int getLastPage() {
        return this.lastPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getCurrentPage() {
        return this.currentPage;
    }

    public int getTotalNum() {
        return this.totalNum;
    }

    public void setTotalNum(int totalNum) {
        this.totalNum = totalNum;
        this.firstPage = totalNum > 0 ? 1 : 0;
        this.totalPages = totalNum % this.pageSize == 0 ? totalNum / this.pageSize : totalNum / this.pageSize + 1;
        this.lastPage = this.totalPages;
        this.currentPage = this.currentPage >= this.totalPages ? this.totalPages : this.currentPage;
        this.currentPage = this.currentPage <= this.firstPage ? this.firstPage : this.currentPage;
        this.startRow = this.currentPage == 0 ? 0 : (this.currentPage - 1) * this.pageSize;
        this.endRow = this.currentPage == this.getLastPage() ? this.getTotalNum() : this.currentPage * this.pageSize;
        this.startRow = this.startRow < 0 ? 0 : this.startRow;
        this.endRow = this.endRow < 0 ? 0 : this.endRow;
    }

    public int getNextPage() {
        return this.currentPage >= this.getLastPage() ? this.getLastPage() : this.currentPage + 1;
    }

    public int getPreviousPage() {
        return this.currentPage <= this.getFirstPage() ? this.getFirstPage() : this.currentPage - 1;
    }

    public int getStartRow() {
        return this.startRow;
    }

    public void setStartRow(int startRow) {
        this.startRow = startRow;
    }

    public int getEndRow() {
        return this.endRow;
    }

    public void setEndRow(int endRow) {
        this.endRow = endRow;
    }

    public void setTotalPages(int totalPages) {
        this.totalPages = totalPages;
    }

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

    public void setFirstPage(int firstPage) {
        this.firstPage = firstPage;
    }

    public void setLastPage(int lastPage) {
        this.lastPage = lastPage;
    }

    public String toString() {
        return "Page [totalPages=" + this.totalPages + ", pageSize=" + this.pageSize + ", currentPage=" + this.currentPage + ", totalNum=" + this.totalNum + "]";
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值