1 changed files with 43 additions and 0 deletions
@ -0,0 +1,43 @@ |
|||
package io.xtfs.jwebfs.utils; |
|||
|
|||
import io.xtfs.jwebfs.constant.ChConstant; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 分页实体 |
|||
* |
|||
*/ |
|||
public class PageBean { |
|||
/** |
|||
* 传入当前页,获得开始位置 |
|||
* @param page |
|||
* @return |
|||
*/ |
|||
public static int calcStartRs(int page){ |
|||
int startRs = page>=1?(page-1)* ChConstant.PAGESIZE :0; |
|||
return startRs; |
|||
} |
|||
/** |
|||
* 传入当前页码,记录总数 |
|||
* @param page |
|||
* @param totalRs |
|||
* @return |
|||
*/ |
|||
public static Map getPageMap(int page, int totalRs){ |
|||
Map xmap = new HashMap(); |
|||
//计算总的页码
|
|||
int pageTotal= totalRs/ ChConstant.PAGESIZE; |
|||
//下页
|
|||
int nextpage=(page+1)<pageTotal?(page+1):pageTotal; |
|||
//上页
|
|||
int prepage = (page-1)>1?page-1:1; |
|||
|
|||
xmap.put("page",page); |
|||
xmap.put("totalpage",pageTotal); |
|||
xmap.put("nextpage",nextpage); |
|||
xmap.put("prepage",prepage); |
|||
return xmap; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue