package com.tsiwebserver.pageService;

import java.util.List;

import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class PageClass {
	private int currentPage;//현재페이지
	private int totPage;//전체페이지
	private int firstRow;//column 첫번째 로우
	private int firstPage;//첫번째 페이지
	private int lastPage;//마지막 페이지
	private List<?> tablelist;//리스트 전체
	private int pagePerCount;//몇개로 짜를건지
	private int totCount;//테이블 개수
	
	private int PAGE_CNT = 10;
	
	public PageClass(int currentPage, int pagePerCount, int totCount) {

		this.currentPage = currentPage;
		this.pagePerCount = pagePerCount;
		this.totCount = totCount;
		this.totPage = (int)Math.ceil((double)totCount/pagePerCount);
		
		if (currentPage > PAGE_CNT) {
			if ((currentPage % PAGE_CNT) == 0) {
				firstPage = (currentPage-1)/PAGE_CNT*PAGE_CNT+1;
			}
			else {
				firstPage = currentPage/PAGE_CNT*PAGE_CNT+1;
			}
		}
		else {
			firstPage = 1;
		}
		
		firstRow = (currentPage-1)*pagePerCount;
		lastPage = firstPage + (PAGE_CNT-1);
		if (lastPage >= totPage) {
			lastPage = totPage;
		}
	}
	
	
}
