package com.iamberry.wechat.core.entity;

import java.util.List;


/**
 * @Description 用于分页，存储分页信息的
 * @author 欧阳明
 * @date 2014-4-19
 */
public class PageBean implements java.io.Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 8970731867434157200L;
	private int count;      //记录总数
	private int pageSize;   //每一页的记录数
	private int pageNumber;  //页码
	private int pageCount;   //总页数
	private int recordBegin ; //查询的开始记录数
	private Object params;
	
	private List<Object> lists;
	private Object condition;
	
	public PageBean(){
		
	}
	
	public PageBean(int count,int pageSize,int recordBegin){
		this.count=count;
		this.pageSize=pageSize;
		this.recordBegin=recordBegin;
	}
	
	public void init(int count,int pageSize,int pageNumber){
		this.count=count;
		this.pageSize=pageSize;
		this.pageNumber=pageNumber;
		initRecordBegin();
	}
	
	public int getCount() {
		return count;
	}
	public void setCount(int count) {
		this.count = count;
	}
	public int getPageSize() {
		if(pageSize==0) return 6;
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getPageNumber() {
		if(this.pageNumber==0)
			this.pageNumber=1;
		return pageNumber;
	}
	public void setPageNumber(int pageNumber) {
		this.pageNumber = pageNumber;
	}
	public int getPageCount() {
		if(pageSize>0 && count>0 ){
			this.pageCount=(int) Math.ceil((double)count/pageSize);
		}else{
			this.pageCount=0;
		}
		return pageCount;
	}
	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}
	public int getRecordBegin() {
		return recordBegin;
	}
	public void setRecordBegin(int recordBegin) {
		this.recordBegin = recordBegin;
	}
	/**
	 * @decription 初始化分页查询的开始记录数
	 */
	public void initRecordBegin(){
		if(pageNumber==1) this.recordBegin = 0;
		if(pageNumber>1){
			this.recordBegin=this.getPageSize()*(this.pageNumber-1);
		}
	}
	
	//获取下一页内容设置
	public void setTurnToNextPage(){
		pageNumber=pageNumber+1;
		initRecordBegin();
	}

	public List<Object> getLists() {
		return lists;
	}

	public void setLists(List<Object> lists) {
		this.lists = lists;
	}

	public Object getCondition() {
		return condition;
	}

	public void setCondition(Object condition) {
		this.condition = condition;
	}

	public Object getParams() {
		return params;
	}

	public void setParams(Object params) {
		this.params = params;
	}

	
	
	
	
}
