package com.intelsrc.bean;

import java.util.List;
@SuppressWarnings("unchecked")
public class PageBean {
	
	private List list ;
	private int allRow;
	private int totalPage;
	public int getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	private int currentPage;
	private int pageSize;
	
	
	private boolean isFirstPage;

	private boolean isLastPage;
	
	private boolean hasNextPage;
	
	private boolean hasPreviousPage;
	
	@SuppressWarnings("unchecked")
	public List getList() {
		return list;
	}
	@SuppressWarnings("unchecked")
	public void setList(List list) {
		this.list = list;
	}
	public int getAllRow() {
		return allRow;
	}
	public void setAllRow(int allRow) {
		this.allRow = allRow;
	}
	
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	
	

	
	public void init(){
		this.isFirstPage=this.isFirstPage();
		this.isLastPage=this.isLastPage();
		this.hasNextPage=this.isHasNextPage();
		this.hasPreviousPage=this.isHasPreviousPage();
		
	}
	
	public boolean isFirstPage() {
		return currentPage==1;
	}
	public boolean isLastPage() {
		return currentPage==totalPage;
	}
	public boolean isHasNextPage() {
		return currentPage!=1;
	}
	public boolean isHasPreviousPage() {
		return currentPage!=totalPage;
	}
	/**
	 * 计算总页数,静态方法,供外部直接通过类名调用
	 * @param pageSize
	 * @param allRow
	 * @return 总页数
	 */
	public static int countToltalPage(final int pageSize,int allRow){
		int toltalPage=allRow%pageSize==0?allRow/pageSize:allRow/pageSize+1;
		return toltalPage;
	}
	/**
	 * 计算当前页开始记录
	 * @param pageSize
	 * @param currentPage
	 * @return  当前页开始记录号
	 */
	public static int countOffset(final int pageSize,final int currentPage){
		final int offset=pageSize*(pageSize-1);
		return offset;
		
	}
	/**
	 * 计算当前页,若为0或者请求的URL中没有"?page=",则用1代替。
	 * @param page  page 传入的参数(可能为空,即0,则返回1)
	 * @return 当前页
	 */
	public static int countCurrentPage(int page){
        final int curPage = (page==0?1:page);
        return curPage;
    }

}
最近下载更多
1322640378  LV1 2021年3月8日
11703060125  LV8 2020年3月27日
谭樊樊  LV7 2019年12月26日
912299793  LV21 2019年10月27日
最代码酒酒  LV20 2019年9月27日
Sotouch  LV15 2019年9月18日
Suoge123  LV13 2019年5月8日
hzhsh0223  LV18 2019年4月13日
猴哥猴哥  LV12 2019年2月25日
wangdongtai  LV31 2018年10月23日
最近浏览更多
斧头帮副帮主  LV5 2023年4月2日
qwdqwdqw  LV3 2022年12月2日
PaymentCodeSystem  LV11 2022年9月9日
17798830  LV14 2022年1月27日
飘忽的茶树  LV9 2021年11月1日
梦本是很好的啦  LV11 2021年9月28日
好的好的  LV8 2021年8月19日
lclinlclin  LV14 2021年4月8日
chi_haoyan  LV1 2021年3月11日
1322640378  LV1 2021年3月8日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友