com.jquicker.model.Pager Maven / Gradle / Ivy
package com.jquicker.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import com.jquicker.commons.util.JsonUtils;
/**
* 分页对象Model
* @param
* @author OL
*/
public class Pager implements Serializable {
private static final long serialVersionUID = -2007702922116505685L;
/**
* 当前页第一条数据的下标(从0开始计数)
*/
private int offset = 0;
/**
* 当前页号
*/
private int pageIndex = 1;
/**
* 每一页包含的记录数
*/
private int pageSize = 10;
/**
* 总记录数
*/
private long totalSize;
/**
* 总页数
*/
private long totalPage;
private List records = new ArrayList();
public Pager() {
super();
}
/**
*
* @param totalSize
* @param pageSize
*
* @author OL
*/
public Pager(int offset, int pageSize) {
super();
this.offset = offset;
this.pageSize = pageSize;
}
public Pager(int offset, int pageSize, long totalSize, List records) {
super();
this.offset = offset;
this.pageSize = pageSize;
this.totalSize = totalSize;
this.records = records;
}
public int getOffset() {
return offset == -1 ? pageSize * (pageIndex - 1) : offset;
}
public void setOffset(int offset) {
this.offset = offset;
}
public int getPageIndex() {
return pageIndex == -1 ? (offset + pageSize) / pageSize : pageIndex;
}
public void setPageIndex(int pageIndex) {
this.pageIndex = pageIndex > 0 ? pageIndex : 1;
}
public int getPageSize() {
return pageSize > 0 ? pageSize : 10;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize > 0 ? pageSize : 10;
}
public long getTotalSize() {
return totalSize;
}
public void setTotalSize(long totalSize) {
this.totalSize = totalSize;
}
public long getTotalPage() {
totalPage = (totalSize + pageSize - 1) / pageSize;
return totalPage;
}
public void setTotalPage(long totalPage) {
this.totalPage = totalPage;
}
public List getRecords() {
return records;
}
public void setRecords(List records) {
this.records = records;
}
@Override
public String toString() {
return JsonUtils.toJsonString(this);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy