Java Code Examples for com.github.pagehelper.Page#addAll()

The following examples show how to use com.github.pagehelper.Page#addAll() . 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 vote down vote up
@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: AbstractHelperDialect.java    From Mybatis-PageHelper with MIT License 6 votes vote down vote up
@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 3
Source File: PageUtil.java    From agile-service-old with Apache License 2.0 5 votes vote down vote up
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();
}