package com.nantian.cloud.jly.vo.util;

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

/**
 * @Author wu yuan hao
 */
public class PageUtils implements Serializable {
	private static final long serialVersionUID = 1L;
	private int total;
	private List<?> records;

	/**
	 * 每页显示条数，默认 10
	 */
	private long size = 10;
	/**
	 * 当前页
	 */
	private long current = 1;

	/**
	 * 总页面
	 */
	private long pages;

	/**
	 * 查询数据开始
	 */
	private  long offset;

	/**
	 * 查询数据结束
	 */
	private  long limit;

	public PageUtils(List<?> list, int total) {
		this.records = list;
		this.total = total;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	public List<?> getRecords() {
		return records;
	}

	public void setRecords(List<?> records) {
		this.records = records;
	}

	public long getSize() {
		return size;
	}

	public void setSize(long size) {
		this.size = size;
	}

	public long getCurrent() {

		return current;
	}

	public void setCurrent(long current) {
		this.current = current;
	}

	public long getPages() {
		if (getSize() == 0) {
			return 0L;
		}
		long pages = getTotal() / getSize();
		if (getTotal() % getSize() != 0) {
			pages++;
		}
		return pages;
	}

	public void setPages(long pages) {
		this.pages = pages;
	}

	public long getOffset() {

		return  (getCurrent()-1) * getSize();
	}

	public void setOffset(long offset) {
		this.offset = offset;
	}

	public long getLimit() {
		return getCurrent() * getSize();
	}

	public void setLimit(long limit) {
		this.limit = limit;
	}
}
