package com.unis.flowable.server.config;
import java.io.Serializable;

import com.github.pagehelper.PageHelper;

public abstract class Page<T extends Page<T>> implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * @Description 页码为首页
	 */
	protected int pageNum = 1;

	/**
	 * @Description 每页显示数量，默认为10
	 */
	protected int pageSize = 10;

	public int getPageNum() {
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	/**
	 * @Title enablePaging
	 * @Description 启用分页
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public final T enablePaging() {
		PageHelper.startPage(pageNum, pageSize);
		return (T) this;
	}

	/**
	 * @Title enablePaging
	 * @Description 启用分页
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public final T enablePage(int pageNum, int pageSize) {
		if (pageSize == 0) {
			pageNum = this.pageNum;
			pageSize = this.pageSize;
		}
		PageHelper.startPage(pageNum, pageSize);
		return (T) this;
	}

}