PageInfo 工具类

package com.jsy.basic.util;


import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import java.util.Map;

public class PageInfo<T> implements Serializable {
	private static final long serialVersionUID = 8545991263226528798L;
	
	@ApiModelProperty(value = "每页数据")
	private List<T> records;
	
	@ApiModelProperty(value = "总记录数")
	private long total;
	
	@ApiModelProperty(value = "每页记录数")
	private long size;
	
	@ApiModelProperty(value = "当前页")
	private long current;
	
	@ApiModelProperty(value = "附加数据")
	private Map<String,Object> extra;
	
	public PageInfo() {
		this.records = Collections.emptyList();
		this.total = 0L;
		this.size = 10L;
		this.current = 1L;
		
	}
	
	public PageInfo(long current, long size) {
		this(current, size, 0L);
	}
	
	public PageInfo(long current, long size, long total) {
		this(current, size, total, true);
	}
	
	public PageInfo(long current, long size, boolean isSearchCount) {
		this(current, size, 0L, isSearchCount);
	}
	
	public PageInfo(long current, long size, long total, boolean isSearchCount) {
		this.records = Collections.emptyList();
		this.total = 0L;
		this.size = 10L;
		this.current = 1L;
		if (current > 1L) {
			this.current = current;
		}
		
		this.size = size;
		this.total = total;
	}
	
	
	public List<T> getRecords() {
		return this.records;
	}
	
	public PageInfo<T> setRecords(List<T> records) {
		this.records = records;
		return this;
	}
	
	public long getTotal() {
		return this.total;
	}
	
	public PageInfo<T> setTotal(long total) {
		this.total = total;
		return this;
	}
	
	public long getSize() {
		return this.size;
	}
	
	public PageInfo<T> setSize(long size) {
		this.size = size;
		return this;
	}
	
	public long getCurrent() {
		return this.current;
	}
	
	public PageInfo<T> setCurrent(long current) {
		this.current = current;
		return this;
	}

	public Map<String, Object> getExtra() {
		return extra;
	}

	public void setExtra(Map<String, Object> extra) {
		this.extra = extra;
	}
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序员小小刘

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值