package com.unis.base.common.vo;

import com.github.pagehelper.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

@Data
@ApiModel(value = "PageResult<T>（分页结果集）", description = "分页结果集")
public class PageResult<T> {

	@ApiModelProperty(value = "总条数")
	private Long total;// 总条数

	@ApiModelProperty(value = "总页数")
	private Integer totalPage;// 总页数

	@ApiModelProperty(value = "当前页")
	private Integer currentPage; // 当前页

	@ApiModelProperty(value = "当前页数据列表")
	private List<T> items;// 当前页数据

	public PageResult() {
	}

	public PageResult(Long total, List<T> items) {
		this.total = total;
		this.items = items;
	}

	public PageResult(Long total, Integer totalPage, List<T> items) {
		this.total = total;
		this.totalPage = totalPage;
		this.items = items;
	}

	public PageResult(Long total, Integer totalPage, Integer currentPage, List<T> items) {
		this.total = total;
		this.totalPage = totalPage;
		this.currentPage = currentPage;
		this.items = items;
	}

	public PageResult(Page<T> pageInfo) {
		this.total = pageInfo.getTotal();
		this.totalPage = pageInfo.getPages();
		this.currentPage = pageInfo.getPageNum();
		this.items = pageInfo;
	}
}
