Springboot分页对象

为了应付一下1024的节日,推荐一下Springboot的分页对象

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

package com.bootcrabframework.cloud.core.component;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel(
    description = "分页对象"
)
public final class Page {
    @ApiModelProperty("总记录数,自动返回,请勿设置")
    private int count;
    @ApiModelProperty("一页显示的数据量")
    private int pageSize = 0;
    @ApiModelProperty("页码,从一开始,比如第一页")
    private int pageNum = 0;
    @ApiModelProperty("排序字段,前端传入")
    private String orderBy;
    @ApiModelProperty("是否需要返回,count 默认是true ")
    private boolean returnCount;

    public void setReturnCount(boolean returnCount) {
        this.returnCount = returnCount;
    }

    public boolean getReturnCount() {
        return this.returnCount;
    }

    public Page() {
        this.returnCount = true;
    }

    public Page(int pageNum, int pageSize) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.returnCount = true;
    }

    public Page(int pageNum, int pageSize, String orderBy) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.orderBy = orderBy;
        this.returnCount = true;
    }

    public String getOrderBy() {
        return this.orderBy;
    }

    public void setOrderBy(String orderBy) {
        this.orderBy = orderBy;
    }

    public int getOffset() {
        return (this.pageNum - 1) * this.pageSize;
    }

    public int getLimit() {
        return this.getOffset() + this.pageSize;
    }

    public int getCount() {
        return this.count;
    }

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

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

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

    public int getPageNum() {
        return this.pageNum;
    }

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

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐