package cn.wolfcode.emp.page;
import java.util.Collections;
import java.util.List;
import javax.management.loading.PrivateClassLoader;
import lombok.Getter;
import lombok.Setter;
@Getter@Setter
public class PageResult {
//数据总条数
private Integer rows;
//每一页的结果集
private List<?> resultlist;
//当前页码
private Integer currentpage;
//每页最多多少条数据
private Integer pagesize;
//下一页
private Integer nextpage;
//上一页
private Integer prevpage;
//总页数
private Integer pagenumber;
public PageResult(Integer rows, List<?> resultlist, Integer currentpage, Integer pagesize) {
this.rows = rows;
this.resultlist = resultlist;
this.currentpage = currentpage;
this.pagesize = pagesize;
this.pagenumber = rows % pagesize == 0 ? rows/pagesize : rows/pagesize+1;
this.nextpage = currentpage < pagenumber ? currentpage+1 : pagenumber;
this.prevpage = currentpage > 1 ? currentpage-1 : 1;
}
public static PageResult empty(Integer pagesize)
{
return new PageResult(0, Collections.EMPTY_LIST, 1, pagesize);
}
}