Java Code Examples for com.github.pagehelper.Page#setTotal()
The following examples show how to use
com.github.pagehelper.Page#setTotal() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PageDeserializer.java From phone with Apache License 2.0 | 6 votes |
@SuppressWarnings({ "unchecked"}) public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) { if (parser.getLexer().token() == JSONToken.NULL) { parser.getLexer().nextToken(JSONToken.COMMA); return null; } String input = parser.getInput(); // final String inputValue = input.replaceAll("\\{.+list:\\[(.++)\\]\\}", "$1"); // ReflectionUtil.setField(ReflectionUtil.findField(parser.getClass(), "input"), parser,inputValue ); Page<T> list = null; if (null==parser.getInput()||"null".equals(input)) { return null; } JSONObject jo = parser.parseObject(); JSONArray ja = jo.getJSONArray("list"); if (ja!=null) { List<T> vList = (List<T>) ja; list = new Page<>(); list.addAll(vList); list.setTotal(jo.getIntValue("total")); } return (T) list; }
Example 2
Source File: JsonUtilTest.java From phone with Apache License 2.0 | 6 votes |
@Test public void seribleList(){ List<Integer> list = new ArrayList<>(); Page<Model> page = new Page<>(); page.setTotal(2); page.add(MyBatisUtil.parseList("abc", "in", "123,345,123")); page.add(MyBatisUtil.parseList("abc", "in", "123,345,123")); System.out.println(JsonUtil.toJsonString(list)); System.out.println(JsonUtil.toJsonString(page)); // List<?> lists = JSON.parseObject(JsonUtil.toJsonString(list),List.class); // System.out.println(JsonUtil.toJsonString(lists)); Page<?> pages = JSON.parseObject(JsonUtil.toJsonString(page),Page.class); System.out.println(JsonUtil.toJsonString(pages)); System.out.println(System.identityHashCode(List.class)); System.out.println(System.identityHashCode(Page.class)); System.out.println(System.identityHashCode(List.class)&1023); System.out.println(System.identityHashCode(Page.class)&1023); }
Example 3
Source File: AbstractHelperDialect.java From Mybatis-PageHelper with MIT License | 6 votes |
@Override public Object afterPage(List pageList, Object parameterObject, RowBounds rowBounds) { Page page = getLocalPage(); if (page == null) { return pageList; } page.addAll(pageList); if (!page.isCount()) { page.setTotal(-1); } else if ((page.getPageSizeZero() != null && page.getPageSizeZero()) && page.getPageSize() == 0) { page.setTotal(pageList.size()); } else if(page.isOrderByOnly()){ page.setTotal(pageList.size()); } return page; }
Example 4
Source File: WxGrouponRuleService.java From BigDataPlatform with GNU General Public License v3.0 | 5 votes |
public List<GrouponRuleVo> queryList(Integer page, Integer size, String sort, String order) { List<LitemallGrouponRules> grouponRulesList = grouponRulesService.queryList(page, size, sort, order); PageInfo pageInfo = new PageInfo(grouponRulesList); Page<GrouponRuleVo> grouponList = new Page<GrouponRuleVo>(); grouponList.setPages(pageInfo.getPages()); grouponList.setPageNum(pageInfo.getPageNum()); grouponList.setPageSize(pageInfo.getPageSize()); grouponList.setTotal(pageInfo.getTotal()); for (LitemallGrouponRules rule : (List<LitemallGrouponRules>)pageInfo.getList()) { Integer goodsId = rule.getGoodsId(); LitemallGoods goods = goodsService.findById(goodsId); if (goods == null) continue; GrouponRuleVo grouponRuleVo = new GrouponRuleVo(); grouponRuleVo.setId(goods.getId()); grouponRuleVo.setName(goods.getName()); grouponRuleVo.setBrief(goods.getBrief()); grouponRuleVo.setPicUrl(goods.getPicUrl()); grouponRuleVo.setCounterPrice(goods.getCounterPrice()); grouponRuleVo.setRetailPrice(goods.getRetailPrice()); grouponRuleVo.setGrouponPrice(goods.getRetailPrice().subtract(rule.getDiscount())); grouponRuleVo.setGrouponDiscount(rule.getDiscount()); grouponRuleVo.setGrouponMember(rule.getDiscountMember()); grouponList.add(grouponRuleVo); } return grouponList; }
Example 5
Source File: WxGrouponRuleService.java From litemall with MIT License | 5 votes |
public List<GrouponRuleVo> queryList(Integer page, Integer size, String sort, String order) { Page<LitemallGrouponRules> grouponRulesList = (Page<LitemallGrouponRules>)grouponRulesService.queryList(page, size, sort, order); Page<GrouponRuleVo> grouponList = new Page<GrouponRuleVo>(); grouponList.setPages(grouponRulesList.getPages()); grouponList.setPageNum(grouponRulesList.getPageNum()); grouponList.setPageSize(grouponRulesList.getPageSize()); grouponList.setTotal(grouponRulesList.getTotal()); for (LitemallGrouponRules rule : grouponRulesList) { Integer goodsId = rule.getGoodsId(); LitemallGoods goods = goodsService.findById(goodsId); if (goods == null) continue; GrouponRuleVo grouponRuleVo = new GrouponRuleVo(); grouponRuleVo.setId(goods.getId()); grouponRuleVo.setName(goods.getName()); grouponRuleVo.setBrief(goods.getBrief()); grouponRuleVo.setPicUrl(goods.getPicUrl()); grouponRuleVo.setCounterPrice(goods.getCounterPrice()); grouponRuleVo.setRetailPrice(goods.getRetailPrice()); grouponRuleVo.setGrouponPrice(goods.getRetailPrice().subtract(rule.getDiscount())); grouponRuleVo.setGrouponDiscount(rule.getDiscount()); grouponRuleVo.setGrouponMember(rule.getDiscountMember()); grouponRuleVo.setExpireTime(rule.getExpireTime()); grouponList.add(grouponRuleVo); } return grouponList; }
Example 6
Source File: PageUtil.java From agile-service-old with Apache License 2.0 | 5 votes |
public static PageInfo buildPageInfoWithPageInfoList(PageInfo pageInfo, List list) { Page page = new Page<>(pageInfo.getPageNum(), pageInfo.getPageSize()); page.setTotal(pageInfo.getTotal()); page.addAll(list); return page.toPageInfo(); }
Example 7
Source File: AbstractHelperDialect.java From Mybatis-PageHelper with MIT License | 5 votes |
@Override public boolean afterCount(long count, Object parameterObject, RowBounds rowBounds) { Page page = getLocalPage(); page.setTotal(count); if (rowBounds instanceof PageRowBounds) { ((PageRowBounds) rowBounds).setTotal(count); } //pageSize < 0 的时候,不执行分页查询 //pageSize = 0 的时候,还需要执行后续查询,但是不会分页 if (page.getPageSize() < 0) { return false; } return count > ((page.getPageNum() - 1) * page.getPageSize()); }