📄 paginationcs.java
字号:
package com.funddeal.base.pagination;
import java.util.ArrayList;
import java.util.Collection;
import com.funddeal.base.PublicFunction;
import com.funddeal.base.interfaces.PaginationInterface;
import com.funddeal.model.dao.config_bring_number.ConfigBringNumberDAO;
import com.funddeal.model.pojo.custom_entity.PaginactionParamEntity;
public class PaginationCs implements PaginationInterface{
public static String errorMsg;
/**
* 得到配置记录数据集(带分页)
* @param pageIndex:当前页
* @param pageSize:每页的记录条数
* @return PageParaPOJO:分页对象实体
* @return pojoName: 分页实体名
*/
public PageParaPOJO searchConfigBringNumJB(int pageIndex,int pageSize ,String pojoName){
errorMsg="";
PageParaPOJO pp=new PageParaPOJO();
PublicFunction pf=new PublicFunction();
//总页数
int resultCount;
//得到总记录数
int resultInt = pf.resultNum(pojoName);
//计算出总页数
int tempInt=pageSize;
if(resultInt%tempInt==0)
resultCount=resultInt/tempInt;
else
resultCount=resultInt/tempInt+1;
//如果当前页大于最大页,当前页为最后一页
if(pageIndex<1)
pageIndex=1;
if(resultCount==0)
resultCount=1;
if(pageIndex>resultCount)
pageIndex=resultCount;
//实例化分页参数实体并赋值
PaginactionParamEntity ppe=new PaginactionParamEntity();
String hql="from " + pojoName;
ppe.setHql(hql);
ppe.setPageIndex(pageIndex);
ppe.setPageSize(pageSize);
//实例化数据访问对象
ConfigBringNumberDAO cbnDAO=new ConfigBringNumberDAO();
//取得数据集
Collection col=cbnDAO.search(ppe);
if(col==null){
errorMsg=ConfigBringNumberDAO.errorMsg;
pp=null;
return pp;
}
try{
pp.setPageArray((ArrayList) col);
pp.setPageCount(resultCount);
pp.setPageIndex(pageIndex);
pp.setPageSize(resultInt);
}catch(Exception ex){
ex.printStackTrace();
}
return pp;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -