当前位置: 首页>>代码示例>>Java>>正文


Java Page类代码示例

本文整理汇总了Java中com.github.pagehelper.Page的典型用法代码示例。如果您正苦于以下问题:Java Page类的具体用法?Java Page怎么用?Java Page使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Page类属于com.github.pagehelper包,在下文中一共展示了Page类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testMapperWithStartPage

import com.github.pagehelper.Page; //导入依赖的package包/类
/**
 * 使用Mapper接口调用时,使用PageHelper.startPage效果更好,不需要添加Mapper接口参数
 */
@Test
public void testMapperWithStartPage() {
    SqlSession sqlSession = MybatisHelper.getSqlSession();
    CountryMapper countryMapper = sqlSession.getMapper(CountryMapper.class);
    try {
        //获取第1页,10条内容,默认查询总数count
        PageHelper.startPage(1, 10);
        List<Country> list = countryMapper.selectAll();
        assertEquals(1, list.get(0).getId());
        assertEquals(10, list.size());
        assertEquals(183, ((Page<?>) list).getTotal());
    } finally {
        sqlSession.close();
    }
}
 
开发者ID:pagehelper,项目名称:Mybatis-PageHelper,代码行数:19,代码来源:TestParameterNone.java

示例2: getUserList

import com.github.pagehelper.Page; //导入依赖的package包/类
@GetMapping("/userListByPage.json")
    @ResponseBody
    @ApiOperation(value = "分页查询用户列表", notes = "不传分页默认1页15条")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页码"),
            @ApiImplicitParam(name = "pageSize", value = "条数")
    })
    public JsonResponse getUserList(@Validated({Search.class}) UserQuery user,
                                    BindingResult bindingResult,
                                    PageKey pageKey)
            throws ValidateException {

        BindingResultUtil.validateResult(bindingResult);
        Page<Object> objects = PageHelper.startPage(pageKey.getPage(), pageKey.getPageSize(), true);
        UserExample example = new UserExample();
        example.createCriteria().andUserNameLike(StringUtil.turn2LikeStr(user.getName()));
        JsonResponse json = new JsonResponse();
        List<User> users = userMapper.selectByExample(example);
        json.putData("list", users);
        System.out.println("**********共有" + objects.getTotal() + "条数据*********");

//        redisTemplate.opsForList().rightPushAll("userList", users);
        return json;
    }
 
开发者ID:DomKing,项目名称:webDemo,代码行数:25,代码来源:DemoController.java

示例3: successWrapper

import com.github.pagehelper.Page; //导入依赖的package包/类
public static Map<String, Object> successWrapper(Page page){

        Map resultMap = new HashMap();
        resultMap.put("code",200);
        resultMap.put("info","success");
        Map<String, Object> paginInfo = new HashMap<String, Object>();
        if( page != null && page.size() > 0 ) {
            long totalNum =page.getTotal();
            long totalPage =page.getPages();
            paginInfo.put("count", totalNum );
            paginInfo.put( "page", page.getPageNum());
            paginInfo.put( "pageCount", totalPage );
            paginInfo.put("list",page);
        } else {
            paginInfo.put( "count", 0 );
            paginInfo.put( "page", 0 );
            paginInfo.put( "pageCount", 0 );
        }
        resultMap.put("object", paginInfo);

        return resultMap;
    }
 
开发者ID:liaojiacan,项目名称:zkAdmin,代码行数:23,代码来源:Result.java

示例4: processPageParameter

import com.github.pagehelper.Page; //导入依赖的package包/类
@Override
public Object processPageParameter(MappedStatement ms, Map<String, Object> paramMap, Page page, BoundSql boundSql, CacheKey pageKey) {
    paramMap.put(PAGEPARAMETER_FIRST, page.getPageSize());
    paramMap.put(PAGEPARAMETER_SECOND, page.getStartRow());
    //处理pageKey
    pageKey.update(page.getPageSize());
    pageKey.update(page.getStartRow());
    //处理参数配置
    if (boundSql.getParameterMappings() != null) {
        List<ParameterMapping> newParameterMappings = new ArrayList<ParameterMapping>();
        if (boundSql != null && boundSql.getParameterMappings() != null) {
            newParameterMappings.addAll(boundSql.getParameterMappings());
        }
        if (page.getPageSize() > 0) {
            newParameterMappings.add(new ParameterMapping.Builder(ms.getConfiguration(), PAGEPARAMETER_FIRST, Integer.class).build());
        }
        if (page.getStartRow() > 0) {
            newParameterMappings.add(new ParameterMapping.Builder(ms.getConfiguration(), PAGEPARAMETER_SECOND, Integer.class).build());
        }
        MetaObject metaObject = MetaObjectUtil.forObject(boundSql);
        metaObject.setValue("parameterMappings", newParameterMappings);
    }
    return paramMap;
}
 
开发者ID:pagehelper,项目名称:Mybatis-PageHelper,代码行数:25,代码来源:HsqldbDialect.java

示例5: processPageParameter

import com.github.pagehelper.Page; //导入依赖的package包/类
@Override
public Object processPageParameter(MappedStatement ms, Map<String, Object> paramMap, Page page, BoundSql boundSql, CacheKey pageKey) {
    paramMap.put(PAGEPARAMETER_FIRST, page.getStartRow());
    paramMap.put(PAGEPARAMETER_SECOND, page.getPageSize());
    //处理pageKey
    pageKey.update(page.getStartRow());
    pageKey.update(page.getPageSize());
    //处理参数配置
    if (boundSql.getParameterMappings() != null) {
        List<ParameterMapping> newParameterMappings = new ArrayList<ParameterMapping>();
        if (page.getStartRow() > 0) {
            newParameterMappings.add(new ParameterMapping.Builder(ms.getConfiguration(), PAGEPARAMETER_FIRST, Integer.class).build());
        }
        if (page.getPageSize() > 0) {
            newParameterMappings.add(new ParameterMapping.Builder(ms.getConfiguration(), PAGEPARAMETER_SECOND, Integer.class).build());
        }
        if (boundSql != null && boundSql.getParameterMappings() != null) {
            newParameterMappings.addAll(boundSql.getParameterMappings());
        }
        MetaObject metaObject = MetaObjectUtil.forObject(boundSql);
        metaObject.setValue("parameterMappings", newParameterMappings);
    }
    return paramMap;
}
 
开发者ID:pagehelper,项目名称:Mybatis-PageHelper,代码行数:25,代码来源:InformixDialect.java

示例6: processPageParameter

import com.github.pagehelper.Page; //导入依赖的package包/类
@Override
public Object processPageParameter(MappedStatement ms, Map<String, Object> paramMap, Page page, BoundSql boundSql, CacheKey pageKey) {
    paramMap.put(PAGEPARAMETER_FIRST, page.getStartRow());
    paramMap.put(PAGEPARAMETER_SECOND, page.getPageSize());
    //处理pageKey
    pageKey.update(page.getStartRow());
    pageKey.update(page.getPageSize());
    //处理参数配置
    if (boundSql.getParameterMappings() != null) {
        List<ParameterMapping> newParameterMappings = new ArrayList<ParameterMapping>();
        if (boundSql != null && boundSql.getParameterMappings() != null) {
            newParameterMappings.addAll(boundSql.getParameterMappings());
        }
        if (page.getStartRow() == 0) {
            newParameterMappings.add(new ParameterMapping.Builder(ms.getConfiguration(), PAGEPARAMETER_SECOND, Integer.class).build());
        } else {
            newParameterMappings.add(new ParameterMapping.Builder(ms.getConfiguration(), PAGEPARAMETER_FIRST, Integer.class).build());
            newParameterMappings.add(new ParameterMapping.Builder(ms.getConfiguration(), PAGEPARAMETER_SECOND, Integer.class).build());
        }
        MetaObject metaObject = MetaObjectUtil.forObject(boundSql);
        metaObject.setValue("parameterMappings", newParameterMappings);
    }
    return paramMap;
}
 
开发者ID:pagehelper,项目名称:Mybatis-PageHelper,代码行数:25,代码来源:MySqlDialect.java

示例7: afterPage

import com.github.pagehelper.Page; //导入依赖的package包/类
@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;
}
 
开发者ID:pagehelper,项目名称:Mybatis-PageHelper,代码行数:17,代码来源:AbstractHelperDialect.java

示例8: testLeftjoin

import com.github.pagehelper.Page; //导入依赖的package包/类
/**
 * left join的count查询sql特殊
 */
@Test
public void testLeftjoin() {
    SqlSession sqlSession = MybatisHelper.getSqlSession();
    CountryMapper countryMapper = sqlSession.getMapper(CountryMapper.class);
    try {
        //获取第1页,10条内容,默认查询总数count
        PageHelper.startPage(1, 10);
        List<Country> list = countryMapper.selectLeftjoin();
        assertEquals(1, list.get(0).getId());
        assertEquals(10, list.size());
        assertEquals(183, ((Page<?>) list).getTotal());

        //获取第1页,10条内容,默认查询总数count
        PageHelper.startPage(2, 10);
        list = countryMapper.selectLeftjoin();
        assertEquals(11, list.get(0).getId());
        assertEquals(10, list.size());
        assertEquals(183, ((Page<?>) list).getTotal());
    } finally {
        sqlSession.close();
    }
}
 
开发者ID:pagehelper,项目名称:Mybatis-PageHelper,代码行数:26,代码来源:TestLeftjoin.java

示例9: outPage

import com.github.pagehelper.Page; //导入依赖的package包/类
public static <T, TO> PageInfo<TO> outPage(Page<T> page, List<TO> tos) {
	if (page == null)
		return new PageInfo<TO>();
	int pageSize = page.getPageSize();
	int pageNo = page.getPageNum();
	long total = page.getTotal();
	return new PageInfo<TO>(pageNo, pageSize, total, tos);
}
 
开发者ID:halober,项目名称:spring-boot-starter-dao,代码行数:9,代码来源:PageUtis.java

示例10: loginSystem

import com.github.pagehelper.Page; //导入依赖的package包/类
/**
 * 登录
 * @param userName
 * @param pwd(密文)
 * @return
 */
@Override
public SysUser loginSystem(String userName, String password) {
	List<Model> conditions = MyBatisUtil.parseBase("LOGIN_NAME,=,"+userName,"PASSWORD,=,"+password);
	Page<SysUser> pages = getBaseMapper().selectExtend(conditions, null, null);
	if (pages.size()==1) {
		getBaseMapper().updateState(pages.get(0).getPk(), "LOGIN_TIME", DateUtil.format(DateUtil.YMD_HMS, new Date()), pages.get(0).getPk());
		return pages.get(0);
	}
	return null;
}
 
开发者ID:leiyong0326,项目名称:phone,代码行数:17,代码来源:SysUserServiceImpl.java

示例11: checkLoginName

import com.github.pagehelper.Page; //导入依赖的package包/类
/**
 * 验证用户名是否可用
 * @param userName
 * @return
 */
@Override
public int checkLoginName(String userName) {
	List<Model> conditions = MyBatisUtil.parseBase("LOGIN_NAME,=,"+userName);
	List<String> columns = new ArrayList<>();
	columns.add("count(1) as count");
	Page<SysUser> pages = getBaseMapper().selectExtend(conditions, columns, null);
	if (pages.size()==0) {
		return 0;
	}
	return pages.get(0).getCount();
}
 
开发者ID:leiyong0326,项目名称:phone,代码行数:17,代码来源:SysUserServiceImpl.java

示例12: findByPage

import com.github.pagehelper.Page; //导入依赖的package包/类
/**
 * 分页查询
 * 
 * @param queryInfo
 * @param pageNum
 * @param pageSize
 * @param orderBy
 * @return
 */ 
@Override
@Logger(model = LogEnum.SysUser, type = LogOperateEnum.Select, title = "")
public Json findByPage(SysUser queryInfo, int pageNum, int pageSize,String orderBy) {
	Json json = new Json();
	Page<SysUser> result = service.findByPage(queryInfo,pageNum,pageSize,orderBy);
	if (result == null) {
		return ErrorConfig.getSystemErrorJson();
	}
	result.forEach((su)->{
		su.setPassword(null);
	});
	json.setSuccess(true).setObj(result).setTotal(result.getPages());
	return json;
}
 
开发者ID:leiyong0326,项目名称:phone,代码行数:24,代码来源:SysUserConsumerServiceImpl.java

示例13: findAll

import com.github.pagehelper.Page; //导入依赖的package包/类
/**
 * 查询所有
 * 
 * @param queryInfo
 * @param orderBy
 * @return
 */ 
@Override
@Logger(model = LogEnum.SysUser, type = LogOperateEnum.Select, title = "")
public Json findAll(SysUser queryInfo, String orderBy) {
	Json json = new Json();
	Page<SysUser> result = service.findAll(queryInfo,orderBy);
	if (result == null) {
		return ErrorConfig.getSystemErrorJson();
	}
	result.forEach((su)->{
		su.setPassword(null);
	});
	json.setSuccess(true).setObj(result);
	return json;
}
 
开发者ID:leiyong0326,项目名称:phone,代码行数:22,代码来源:SysUserConsumerServiceImpl.java

示例14: findByExport

import com.github.pagehelper.Page; //导入依赖的package包/类
/**
 * 导出
 * 
 * @param conditions
 * @param orderBy
 * @return
 */ 
@Override
@Logger(model = LogEnum.SysUser, type = LogOperateEnum.Export, title = "")
public Json findByExport(List<Model> conditions, String orderBy) {
	Json json = new Json();
	Page<SysUser> result = service.findAll(conditions,orderBy);
	if (result == null) {
		return ErrorConfig.getSystemErrorJson();
	}
	result.forEach((su)->{
		su.setPassword(null);
	});
	json.setSuccess(true).setObj(result);
	return json;
}
 
开发者ID:leiyong0326,项目名称:phone,代码行数:22,代码来源:SysUserConsumerServiceImpl.java

示例15: deserialze

import com.github.pagehelper.Page; //导入依赖的package包/类
@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;
    }
 
开发者ID:leiyong0326,项目名称:phone,代码行数:26,代码来源:PageDeserializer.java


注:本文中的com.github.pagehelper.Page类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。