package com.inkasso.factoring.common.entity;

import com.alibaba.fastjson.annotation.JSONField;

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

public class GridPage<T> implements Serializable {

	private static final long serialVersionUID = 1L;
	/** 每页数据条数 */
	@JSONField(serialize = false)
	private long pageNum = 10;
	/** 当前页 */
	private long page = 1;
	/** 总页数 */
	private long total = 1;
	/** 查询出的记录数 */
	private long records = 1;
	/** 实际数据集合 */
	private List<T> rows;
	/**
	 * 响应码
	 */
	private String code = "200";

	private Boolean success = true;

	public Boolean getSuccess() {
		return success;
	}

	public void setSuccess(Boolean success) {
		this.success = success;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public long getPageNum() {
		return pageNum;
	}

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

	public long getPage() {
		return page;
	}

	public void setPage(long page) {
		this.page = page;
	}

	public long getTotal() {
		return total;
	}

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

	public long getRecords() {
		return records;
	}

	public void setRecords(long records) {
		this.records = records;
	}

	public List<T> getRows() {
		return rows;
	}

	public void setRows(List<T> rows) {
		this.rows = rows;
	}

	/**
	 * @param pageNum
	 *            每页数据条数
	 * @param page
	 *            当前页
	 * @param count
	 *            查询总记录数
	 * @param list
	 *            数据集合
	 */
	public GridPage(long pageNum, long page, long count, List<T> list) {
		setPage(page);
		setRecords(count);
		setRows(list);
		if (count % pageNum > 0) {
			setTotal((int) (count / pageNum) + 1);
		} else {
			setTotal((int) (count / pageNum));
		}
	}

	public GridPage(List<T> list) {
		setRecords(list.size());
		setRows(list);
	}

	public GridPage() {
		super();
	}
}
