package com.njcn.pojo.commons.area;

import java.util.List;

/**
 * 暂降事件列表的响应体
 * */
public class ResponseVoltageList {

	private Integer pageNum;// 当前页码

	private Integer pageSize;// 每页记录数

	private Integer totalPages;// 总页码

	private Integer totalCouts;// 总记录

	private List<VoltageDetail> volList;// 分页显示数据

	private Integer nextPage;// 下一页

	private Integer beforePage;// 上一页

	private int[] pageBar;


	public List<VoltageDetail> getVolList() {
		return volList;
	}

	public void setVolList(List<VoltageDetail> volList) {
		this.volList = volList;
	}

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

	public int getPageNum()
	{
		return pageNum;
	}

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

	public int getPageSize()
	{
		return pageSize;
	}

	// 总页码 计算出来 总记录数 每页显示记录数
	public int getTotalPages()
	{

		this.totalPages = (this.totalCouts + this.pageSize - 1) / this.pageSize;
		return this.totalPages;
	}

	// 总记录数 数据库查询
	public void setTotalCouts(int totalCouts)
	{
		this.totalCouts = totalCouts;
	}

	public int getTotalCouts()
	{
		return totalCouts;
	}

	// 下一页封装
	public int getNextPage()
	{
		this.nextPage = this.pageNum + 1;
		if (this.nextPage >= this.totalPages)
		{
			this.nextPage = this.totalPages;
		}
		return this.nextPage;
	}

	// 上一页封装
	public int getBeforePage()
	{
		this.beforePage = this.pageNum - 1;
		if (this.beforePage <= 0)
		{
			this.beforePage = 1;
		}
		return this.beforePage;
	}

	// 分页栏
	public int[] getPageBar()
	{
		// 根据当前页码和总页码计算页码栏首位数字和末尾数字
		int beginPage;
		int endPage;
		if (this.totalPages <= 7)
		{
			beginPage = 1;
			endPage = this.totalPages;
		} else
		{
			beginPage = this.pageNum - 3;
			endPage = this.pageNum + 3;
			if (beginPage <= 0)
			{
				beginPage = 1;
				endPage = beginPage + 6;
			}
			if (endPage > this.totalPages)
			{
				beginPage = this.totalPages - 6;
				endPage = this.totalPages;
			}
		}
		this.pageBar = new int[endPage - beginPage + 1];
		int index = 0;
		for (int i = beginPage; i <= endPage; i++)
		{
			pageBar[index++] = i;
		}
		return pageBar;
	}
}
