package com.ht.util;
public class BasePage{
public static final Integer DEFAULT_CURRENT=1;
public static final Integer DEFAULT_PAGE_NUM=10;
protected Integer pageFirRecord=0;
protected Integer currentPage=1;
protected Integer totalPages;
protected Integer totalRecord;
protected Integer showRecordNum=DEFAULT_PAGE_NUM;
protected Integer showPageNum;
protected Integer prePage=1;
protected Integer nexePage=1;
public BasePage(){
}
public BasePage(Integer currentPage,Integer totalRecord){
this.setTotalRecord(totalRecord);
this.setTotalPages();
this.setCurrentPage(currentPage);
this.setShowPageNum();
this.setPageFirRecord();
this.setPrePage();
this.setNexePage();
}
public BasePage(Integer currentPage,Integer totalRecord,int showRecordNum){
this.setTotalRecord(totalRecord);
this.setShowRecordNum(showRecordNum);
this.setTotalPages();
this.setCurrentPage(currentPage);
this.setShowPageNum();
this.setPageFirRecord();
this.setPrePage();
this.setNexePage();
}
public Integer getPrePage() {
return prePage;
}
public void setPrePage() {
this.prePage = currentPage-1;
}
public Integer getNexePage() {
return nexePage;
}
public void setNexePage() {
if(currentPage==totalPages){
this.nexePage = 0;
}else{
this.nexePage = currentPage+1;
}
if(totalPages==0){
this.nexePage = 0;
}
}
public Integer getShowPageNum() {
return showPageNum;
}
public void setShowPageNum() {
if(currentPage*showRecordNum-totalRecord>0){
this.showPageNum = totalRecord-(currentPage-1)*showRecordNum;
}else{
this.showPageNum=showRecordNum;
}
}
public Integer getShowRecordNum() {
return showRecordNum;
}
public void setShowRecordNum(Integer showRecordNum) {
if(showRecordNum==0){
this.showRecordNum=5;
}else{
this.showRecordNum = showRecordNum;
}
}
public Integer getTotalPages() {
return totalPages;
}
public void setTotalPages() {
if(totalRecord%showRecordNum==0){
this.totalPages = totalRecord/showRecordNum;
}else{
this.totalPages = totalRecord/showRecordNum+1;
}
}
public Integer getTotalRecord() {
return totalRecord;
}
public void setTotalRecord(Integer totalRecord) {
this.totalRecord = totalRecord;
}
public Integer getCurrentPage() {
return currentPage;
}
public void setCurrentPage(Integer currentPage) {
if(currentPage==0||currentPage<0){
currentPage=1;
}
if(currentPage>totalPages&&totalPages!=0){
this.currentPage=totalPages;
}else if(totalPages==0){
this.currentPage=1;
}else{
this.currentPage = currentPage;
}
}
public void setPageFirRecord() {
this.pageFirRecord = (getCurrentPage()-1)*showRecordNum;
}
public Integer getPageFirRecord() {
return pageFirRecord;
}
}
评论4
最新资源