/**
* @title 分页封装类
* @description 用户分页相关的数据封装
* @author maohuidong
* @date 2017-04-06
*/
public class PageBean<T> {
//第几页
private int pageNum;
//每页显示的条数
private int pageSize;
//总共多少页
private int totalPage;
//总共多少数据
private int totalRecord;
//数据
private List<T> dataList;
//可选项(在没有总页数的情况下,失效)
private int start;
private int end;
/**
*
* @param pageNum
* @param pageSize
* @param totalRecord
*/
public PageBean(int pageNum, int pageSize, int totalRecord,List<T> dataList) {
this.pageNum = pageNum;
this.pageSize = pageSize;
this.totalRecord = totalRecord;
this.totalPage = (totalRecord + (pageSize - 1)) / pageSize;
this.dataList = dataList;
//可选项
start = 1;
end = 10;
if(this.totalPage <= 10){
end = totalPage;
}else{
start = this.pageNum - 5;
end = this.pageNum + 4;
if(start < 1){
start = 1;
end = 10;
}
if(end > this.totalPage){
start = this.totalPage - 9;
end = this.totalPage;
}
}
}
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;
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public int getTotalRecord() {
return totalRecord;
}
public void setTotalRecord(int totalRecord) {
this.totalRecord = totalRecord;
}
public List<T> getDataList() {
return dataList;
}
public void setDataList(List<T> dataList) {
this.dataList = dataList;
}
public int getStart() {
return start;
}
public void setStart(int start) {
this.start = start;
}
public int getEnd() {
return end;
}
public void setEnd(int end) {
this.end = end;
}
}