Springboot分页对象

Posted 皓洲

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Springboot分页对象相关的知识,希望对你有一定的参考价值。

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;
    


以上是关于Springboot分页对象的主要内容,如果未能解决你的问题,请参考以下文章

Springboot分页对象

springboot+thymeleaf处理带搜索条件的分页问题解决思路

springboot修改了端口后分页查询失效了

解决Springboot2.x版本pagehelper分页不生效的问题

解决Springboot2.x版本pagehelper分页不生效的问题

解决Springboot2.x版本pagehelper分页不生效的问题