本文整理汇总了Java中com.jfinal.plugin.activerecord.Page类的典型用法代码示例。如果您正苦于以下问题:Java Page类的具体用法?Java Page怎么用?Java Page使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Page类属于com.jfinal.plugin.activerecord包,在下文中一共展示了Page类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: index
import com.jfinal.plugin.activerecord.Page; //导入依赖的package包/类
/**
* 试题列表
*/
public void index() {
int pageNum = Convert.toInteger(getPara("pageNumber", "1"));
int pageSize = Convert.toInteger(getPara("pageSize", String.valueOf(10)));
String type = getPara(0);
Page<Test> t = Test.dao.pageQuery(pageNum, pageSize, type);
setAttr("page", 3);
setAttr("leftPage", type);
setAttr("examPage", t);
if (t != null) {
setPage(t);
setAttr("pageUrl", "/exam/" + type);
}
Test test = Test.findExamCountByType(getUser().getInt("id"));
ExamBean bean = new ExamBean();
bean.setAll(test.get("allexam").toString());
bean.setLow(test.get("low").toString());
bean.setMiddle(test.get("middle").toString());
bean.setHeight(test.get("height").toString());
bean.setMyTest(test.get("myCount").toString());
setAttr("examCount",bean);
render("index.jsp");
}
示例2: myTests
import com.jfinal.plugin.activerecord.Page; //导入依赖的package包/类
/**
* 我做过的试卷列表
*/
public void myTests(){
int pageNum = Convert.toInteger(getPara("pageNumber", "1"));
int pageSize = Convert.toInteger(getPara("pageSize", String.valueOf(10)));
Page<Reply> r = Reply.dao.findTestByUser(pageNum,pageSize,getUser().getInt("id"));
setAttr("page",3);
setAttr("leftPage", 6);
setAttr("testPage", r);
if (r != null) {
setPage(r);
setAttr("pageUrl", "/exam/myTests");
}
Test test = Test.findExamCountByType(getUser().getInt("id"));
ExamBean bean = new ExamBean();
bean.setAll(test.get("allexam").toString());
bean.setLow(test.get("low").toString());
bean.setMiddle(test.get("middle").toString());
bean.setHeight(test.get("height").toString());
bean.setMyTest(test.get("myCount").toString());
setAttr("examCount",bean);
}
示例3: query_slice
import com.jfinal.plugin.activerecord.Page; //导入依赖的package包/类
public Page<Record> query_slice( int tabletype,int pageNum, int numPerPage) {
Page<Record> recpage;
List<Object> sqlParam = new ArrayList<Object>();
String sql = null;
switch(tabletype){
case 1:{
sql=" from score m1 JOIN (SELECT m2.id,m2.version,count(DISTINCT version) from score m2 GROUP BY m2.version) as m2 on m1.id=m2.id join (SELECT m3.id,m3.version,count(DISTINCT version) from score m3 GROUP BY m3.version) as m3 ON m1.id=m3.id " ;
break;
}
case 2:{
sql="";
break;
}
case 3:{
sql="";
break;
}
case 4:{
sql="";
break;
}
}
recpage = Db.paginate(pageNum, numPerPage,"SELECT m1.projectType,m1.version ", sql,sqlParam.toArray());
return recpage;
}
示例4: paginate
import com.jfinal.plugin.activerecord.Page; //导入依赖的package包/类
/**
* 分页查询
*
* @param collection
* @param pageNumber
* @param pageSize
* @param filter
* @param like
* @param sort
* @return
*/
public static Page<Record> paginate(String collection, int pageNumber, int pageSize, BasicDBObject filter, BasicDBObject like, BasicDBObject sort) {
BasicDBObject conditons = new BasicDBObject();
buildFilter(filter, conditons);
buildLike(like, conditons);
MongoCursor<Document> cursor = getCollection(collection).find(conditons)
.skip((pageNumber - 1) * pageSize).limit(pageSize).sort(sort(sort)).iterator();
List<Record> records = new ArrayList<>();
Long totalRow = getCollection(collection).count(conditons);
while (cursor.hasNext()) {
records.add(toRecord(cursor.next()));
}
if (totalRow <= 0) {
return new Page<>(new ArrayList<Record>(0), pageNumber, pageSize, 0, 0);
}
Long totalPage = totalRow / pageSize;
if (totalRow % pageSize != 0) {
totalPage++;
}
Page<Record> page = new Page<>(records, pageNumber, pageSize, totalPage.intValue(), totalRow.intValue());
return page;
}
示例5: getEmptyList
import com.jfinal.plugin.activerecord.Page; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static List<Actor> getEmptyList() {
Page<User> pages = User.me.paginate(1, 100);
List<Actor> actors = new ArrayList<Actor>();
for (User m : pages.getList()) {
Actor a = me.new Actor(m.get("phone").toString(), m.get("name")
.toString());
actors.add(a);
}
ApiResult ret = UserApi.getFollows(0);
ArrayList<Object> list = ret.getList("userlist");
LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>();
for (Object obj : list) {
map = (LinkedHashMap<String, Object>) obj;
actors.remove(me.new Actor(map.get("userid").toString(), ""));
}
return actors;
}
示例6: paginate
import com.jfinal.plugin.activerecord.Page; //导入依赖的package包/类
/**
* Paging retrieve, default sorted by id, you need to specify the datatables request parameters.
*
* @param sqlPaginatePrefix 分页搜索前缀
* @param pageDto required parameter.
* @return Paging data.
*/
public static Page<Record> paginate(String sqlPaginatePrefix,
PageDto pageDto) {
SqlNode sqlNode = SqlKit.sqlNode(sqlPaginatePrefix + ".paginate");
Preconditions.checkNotNull(sqlNode, "[" + sqlPaginatePrefix + ".paginate]分页Sql不存在,无法执行分页");
String where = sqlNode.whereSql;
int pageSize = pageDto.pageSize;
int p = pageDto.page;
int start = ((p - 1) * pageSize) + 1;
final List<RequestParam> params = pageDto.params;
final List<Object> query_params = pageDto.query_params;
if ((params.isEmpty()) && (query_params.isEmpty())) {
return Db.paginate(start, pageSize, sqlNode.selectSql, where);
} else {
if (!params.isEmpty()) {
where += (sqlNode.condition ? StringPool.SPACE : " WHERE 1=1 ");
}
for (RequestParam param : pageDto.params) {
where += param.toSql();
}
return Db.paginate(start, pageSize, sqlNode.selectSql, where, query_params.toArray());
}
}
示例7: getPagationList
import com.jfinal.plugin.activerecord.Page; //导入依赖的package包/类
public Page<WcMsg> getPagationList(String tenantId, int pageNumber, int pageSize, String contentKeys) {
String select = "select wx_msg.*,wx_fans.nickname,wx_fans.headimgurl ";
StringBuilder sqlBuilder = new StringBuilder(
"from wx_msg left join wx_fans on wx_msg.fromuser=wx_fans.id where 1=1 and msg_type='text' ");
List<Object> params = new ArrayList<>();
if (StringUtils.hasText(tenantId)) {
sqlBuilder.append(" and wx_msg.tenant_id=? ");
params.add(tenantId);
}
if (StringUtils.hasText(contentKeys)) {
sqlBuilder.append(" and wx_msg.msg_content like ? ");
params.add("%" + contentKeys + "%");
}
sqlBuilder.append(" order by wx_msg.id desc");
return dao.paginate(pageNumber, pageSize, select, sqlBuilder.toString(), params.toArray());
}
示例8: getPagationList
import com.jfinal.plugin.activerecord.Page; //导入依赖的package包/类
public Page<Fans> getPagationList(String tenantId, String province, String city, String nickname, int pageNumber,
int pageSize) {
String select = "select * ";
StringBuilder sqlBuilder = new StringBuilder("from wx_fans where 1=1 ");
List<Object> params = new ArrayList<>();
if (StringUtils.hasText(tenantId)) {
sqlBuilder.append(" and tenant_id=? ");
params.add(tenantId);
}
if (StringUtils.hasText(province)) {
sqlBuilder.append(" and province like ? ");
params.add("%" + province + "%");
}
if (StringUtils.hasText(city)) {
sqlBuilder.append(" and city like ? ");
params.add("%" + city + "%");
}
if (StringUtils.hasText(nickname)) {
sqlBuilder.append(" and nickname like ? ");
params.add("%" + nickname + "%");
}
sqlBuilder.append(" order by id desc");
return dao.paginate(pageNumber, pageSize, select, sqlBuilder.toString(), params.toArray());
}
示例9: getConfigList
import com.jfinal.plugin.activerecord.Page; //导入依赖的package包/类
public Page<WcConfig> getConfigList(PageBean<WcConfig> pageBean) {
String select = "SELECT * ";
StringBuffer sqlBuilder = new StringBuffer(" FROM SYS_WX_CONFIG WHERE 1=1");
List<Object> params = new ArrayList<>();
if (StringUtils.isNotBlank(pageBean.getExt().get("tenant_id"))) {
sqlBuilder.append(" AND TENANT_ID = ?");
params.add(pageBean.getExt().get("tenant_id"));
}
if (StringUtils.isNotBlank(pageBean.getExt().get("wx_no"))) {
sqlBuilder.append(" AND WX_NO LIKE ?");
params.add("%" + pageBean.getExt().get("wx_no") + "%");
}
if (StringUtils.isNotBlank(pageBean.getExt().get("name"))) {
sqlBuilder.append(" AND NAME LIKE ?");
params.add("%" + pageBean.getExt().get("name") + "%");
}
sqlBuilder.append(" ORDER BY UPDATE_TIME DESC ");
return dao.paginate(pageBean.getPageNo(), pageBean.getPageSize(), select, sqlBuilder.toString(),
params.toArray());
}
示例10: index
import com.jfinal.plugin.activerecord.Page; //导入依赖的package包/类
@RequiresRoles(value = { "管理员", "超级管理员" }, logical = Logical.OR)
public void index() {
int pageNum = Convert.toInteger(getPara("pageNumber", "1"));
int pageSize = Convert.toInteger(getPara("pageSize", String.valueOf(_defaultNumPerPage)));
Page<User> UserPage = BGDispatch.userService.query_sort(pageNum, pageSize, getUser());
if (UserPage != null) {
setPage(UserPage);
setAttr("UserPage", UserPage);
setAttr("pageUrl", "/user");
}
this.setAttr("page", 3);
render("userList.jsp");
}
示例11: setPage
import com.jfinal.plugin.activerecord.Page; //导入依赖的package包/类
/**
* 计算分页
*
* @param pageData
* @return
* @throws java.io.UnsupportedEncodingException
*
*/
protected void setPage(Page pageData) {
int pageNum = pageData.getPageNumber();
int totalRow = pageData.getTotalRow();
int numPerPage = pageData.getPageSize();
int totalPage = pageData.getTotalPage();
setAttr("totalRow", totalRow);// 总数
setAttr("numPerPage", numPerPage);// 每页数
setAttr("curPage", pageNum);// 当前页码
setAttr("totalPage", totalPage);// 总页数
setAttr("beginPage", pageNum - 4 < 1 ? 1 : pageNum - 4);// 开始页码
setAttr("endPage", pageNum + 4 > totalPage ? totalPage : pageNum + 4);// 结束页码
}
示例12: searchPaginate
import com.jfinal.plugin.activerecord.Page; //导入依赖的package包/类
public Page<M> searchPaginate(int pageNumber, int pageSize,
Map<String, Object> maps, String orderBy) {
StringBuilder sb = new StringBuilder();
String tableName = TableInfoMapping.me().getTableInfo(getClass())
.getTableName();
sb.append("from ").append(tableName).append(" where 1=1");
List<Object> values = setMap(maps, sb);
sb.append( orderBy);
Object[] obj = values.toArray();
return paginate(pageNumber, pageSize, "select *", sb.toString(),obj);
}
示例13: searchPaginateByCache
import com.jfinal.plugin.activerecord.Page; //导入依赖的package包/类
public Page<M> searchPaginateByCache(String cacheName, Object key,
int pageNumber, int pageSize, Map<String, Object> maps,
String orderBy) {
// checkTableName();
ICache cache = DbKit.getCache();
Page<M> result = cache.get(cacheName, key);
if (result == null) {
result = searchPaginate(pageNumber, pageSize, maps, orderBy);
cache.put(cacheName, key, result);
}
return result;
}
示例14: pageQuery
import com.jfinal.plugin.activerecord.Page; //导入依赖的package包/类
public Page<Test> pageQuery(int pagenum, int pagesize, String type) {
String where = "";
if (!type.equals("all")) {
where = "where difficulty=" + type;
}
return paginate(pagenum, pagesize, "select *", " from test " + where +" order by id desc");
}
示例15: query_sort
import com.jfinal.plugin.activerecord.Page; //导入依赖的package包/类
public Page<User> query_sort(int pageNum, int numPerPage,User currentUser) {
Page<User> userPage;
try{
//������ݿ�Fitter
String sqlFitter = getSqlFitter();
List<Object> sqlParam = new ArrayList<Object>();
userPage = User.dao.paginate(pageNum, numPerPage, "SELECT *","FROM " + TableName + sqlFitter,sqlParam.toArray());
return userPage;
}catch(Exception e) {
e.printStackTrace();
}
return null;
}