package jj.tech.paolu.utils;

import java.util.List;

public class Page {
	
	private Integer pageSize=20;	//页多少条
	private Integer pageNum=1;		//第几页
	private Long total=0L;			//一共多少条
	private Long totalPage;			//一共几页
	
	private List<?> list;
	
	public Page() {
		
	}
	
	public Page(Integer pageNum, Integer pageSize) {
		this.setPageNum(pageNum);
		this.setPageSize(pageSize);
	}
	
	
	

	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(Integer pageSize) {
		if(pageSize != null && pageSize >= 1){
			this.pageSize = pageSize;
		}
	}
	public int getPageNum() {
		return pageNum;
	}
	public void setPageNum(Integer pageNum) {
		if(pageNum != null && pageNum >= 1){
			this.pageNum = pageNum;
		}
	}
	public Long getTotal() {
		return total;
	}
	public void setTotal(Long total) {
		this.total = total;
	}
	public Long getTotalPage() {
		Integer t = (int) Math.ceil((double) total / pageSize);
		totalPage = t.longValue();
		return totalPage;
	}
	public void setTotalPage(Long totalPage) {
		this.totalPage = totalPage;
	}
	public List<?> getList() {
		return list;
	}
	public void setList(List<?> list) {
		this.list = list;
	}
	
	
	public int limitStart(){
		return (pageNum - 1) * pageSize;
	}
	
}
