分页工具类
package com.fsx.entity;
import java.io.Serializable;
import java.util.ArrayList;
/**
* Author: 青铜大佬
* Date: 2021/3/13 9:29
* 分页工具类
*/
public class Page<T> implements Serializable {
private ArrayList<T> dataList;//对象集合
private int totalCount = 0;//总记录数
private int currentPage;//当前页
private int MAX_ROW = 10;//每页显示的最大记录数
public Page() {
}
public Page(ArrayList<T> dataList, int totalCount, int currentPage, int MAX_ROW) {
this.dataList = dataList;
this.totalCount = totalCount;
this.currentPage = currentPage;
this.MAX_ROW = MAX_ROW;
}
public ArrayList<T> getDataList() {
return dataList;
}
public void setDataList(ArrayList<T> dataList) {
this.dataList = dataList;
}
public int getTotalCount() {
return totalCount;
}
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
//得到符合条件的总页数
public int getTotalPage() {
return (int) Math.ceil(getTotalCount() * 1.0 / getMAX_ROW());
}
public int getCurrentPage() {
return currentPage;
}
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
//得到起始下标
public int getIndex() {
return (getCurrentPage() - 1) * getMAX_ROW();
}
public int getMAX_ROW() {
return MAX_ROW;
}
public void setMAX_ROW(int MAX_ROW) {
this.MAX_ROW = MAX_ROW;
}
}