本文整理汇总了Java中com.github.pagehelper.PageHelper类的典型用法代码示例。如果您正苦于以下问题:Java PageHelper类的具体用法?Java PageHelper怎么用?Java PageHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PageHelper类属于com.github.pagehelper包,在下文中一共展示了PageHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOrderList
import com.github.pagehelper.PageHelper; //导入依赖的package包/类
public ServerResponse<PageInfo> getOrderList(Integer userId, int pageNum, int pageSize){
PageHelper.startPage(pageNum,pageSize);
List<Order> orderList = orderMapper.selectByUserId(userId);
List<OrderVo> orderVoList = assembleOrderVoList(orderList,userId);
PageInfo pageResult = new PageInfo(orderList);
pageResult.setList(orderVoList);
return ServerResponse.createBySuccess(pageResult);
}
示例2: getOrderList
import com.github.pagehelper.PageHelper; //导入依赖的package包/类
@Override
public ServerResponse<PageInfo> getOrderList(Integer userId, int pageNum, int pageSize) {
PageHelper.startPage(pageNum, pageSize);
List<Order> orderList = orderMapper.selectByUserId(userId);
List<OrderVo> orderVoList = assembleOrderVoList(orderList, userId);
PageInfo pageResult = new PageInfo(orderList);
pageResult.setList(orderVoList);
return ServerResponse.createBySuccess(pageResult);
}
示例3: searchProduct
import com.github.pagehelper.PageHelper; //导入依赖的package包/类
@Override
public ServerResponse<PageInfo> searchProduct(String productName, Integer productId, int pageNum, int pageSize) {
PageHelper.startPage(pageNum, pageSize);
if (StringUtils.isNotBlank(productName)) {
productName = new StringBuilder().append("%").append(productName).append("%").toString();
}
List<Product> productList = productMapper.selectByNameAndProductId(productName, productId);
List<ProductListVo> productListVoList = Lists.newArrayList();
for (Product productItem : productList) {
ProductListVo productListVo = assembleProductListVo(productItem);
productListVoList.add(productListVo);
}
PageInfo pageResult = new PageInfo(productList);
pageResult.setList(productListVoList);
return ServerResponse.createBySuccess(pageResult);
}
示例4: testPageHelper
import com.github.pagehelper.PageHelper; //导入依赖的package包/类
@Test
public void testPageHelper() {
//创建一个spring容器
ApplicationContext applicationContext =
new ClassPathXmlApplicationContext("classpath:spring/applicationContext-*.xml");
//送spring容器中获得mapper代理对象
TbItemMapper itemMapper = applicationContext.getBean(TbItemMapper.class);
//执行查询并分页
TbItemExample tbItemExample = new TbItemExample();
//分页处理
PageHelper.startPage(1, 10);
List<TbItem> list = itemMapper.selectByExample(tbItemExample);
//获取商品列表
for (TbItem tbItem : list) {
System.out.println(tbItem.getTitle());
}
//取分页信息
PageInfo<TbItem> pageInfo = new PageInfo<>(list);
long total = pageInfo.getTotal();
System.out.println("共有商品:" + total);
}
示例5: getCategoryList
import com.github.pagehelper.PageHelper; //导入依赖的package包/类
@Override
public Map<String, Object> getCategoryList(Integer sEcho, Integer iDisplayStart, Integer iDisplayLength) {
HashMap<String, Object> map = new HashMap<>();
int pageNum = iDisplayStart / iDisplayLength + 1;
//System.out.println(pageNum);
PageHelper.startPage(pageNum, iDisplayLength);
TbCategoryExample example = new TbCategoryExample();
TbCategoryExample.Criteria criteria = example.createCriteria();
criteria.andSortOrderEqualTo(1);
List<TbCategory> list = categoryMapper.selectByExample(example);
//System.out.println(list.size());
PageInfo<TbCategory> pageInfo = new PageInfo<>(list);
map.put("sEcho", sEcho + 1);
map.put("iTotalRecords", pageInfo.getTotal());//数据总条数
map.put("iTotalDisplayRecords", pageInfo.getTotal());//显示的条数
map.put("aData", list);//数据集合
return map;
}
示例6: getSearchCategorySecondaryList
import com.github.pagehelper.PageHelper; //导入依赖的package包/类
@Override
public Map<String, Object> getSearchCategorySecondaryList(String sSearch, Integer sEcho, Integer iDisplayStart, Integer iDisplayLength) {
HashMap<String, Object> map = new HashMap<>();
int pageNum = iDisplayStart / iDisplayLength + 1;
//System.out.println(pageNum);
PageHelper.startPage(pageNum, iDisplayLength);
TbCategorySecondaryExample example = new TbCategorySecondaryExample();
TbCategorySecondaryExample.Criteria criteria = example.createCriteria();
criteria.andNameLike("%" + sSearch + "%");
List<TbCategorySecondary> list = categorySecondaryMapper.selectByExample(example);
//System.out.println(list.size());
PageInfo<TbCategorySecondary> pageInfo = new PageInfo<>(list);
map.put("sEcho", sEcho + 1);
map.put("iTotalRecords", pageInfo.getTotal());//数据总条数
map.put("iTotalDisplayRecords", pageInfo.getTotal());//显示的条数
map.put("aData", list);//数据集合
return map;
}
示例7: test
import com.github.pagehelper.PageHelper; //导入依赖的package包/类
@Test
public void test(){
SqlSession sqlSession = MybatisHelper.getSqlSession();
CountryMapper countryMapper = sqlSession.getMapper(CountryMapper.class);
Example example = new Example(Country.class);
example.createCriteria().andGreaterThan("id",100);
PageHelper.startPage(2,10);
/*SELECT Id,countryname,countrycode FROM country WHERE ( Id > ? )*/
List<Country> countries = countryMapper.selectByExample(example);
PageInfo<Country> pageInfo = new PageInfo<Country>(countries);
System.out.println(pageInfo.getTotal());
countries = countryMapper.selectByExample(example);
pageInfo = new PageInfo<Country>(countries);
System.out.println(pageInfo.getTotal());
}
示例8: getItemList
import com.github.pagehelper.PageHelper; //导入依赖的package包/类
@Override
public DataTablesResult getItemList(int draw, int start, int length, int cid, String search,
String orderCol, String orderDir) {
DataTablesResult result=new DataTablesResult();
//分页执行查询返回结果
PageHelper.startPage(start/length+1,length);
List<TbItem> list = tbItemMapper.selectItemByCondition(cid,"%"+search+"%",orderCol,orderDir);
PageInfo<TbItem> pageInfo=new PageInfo<>(list);
result.setRecordsFiltered((int)pageInfo.getTotal());
result.setRecordsTotal(getAllItemCount().getRecordsTotal());
result.setDraw(draw);
result.setData(list);
return result;
}
示例9: pageSearch
import com.github.pagehelper.PageHelper; //导入依赖的package包/类
/**
* 分页查询
*
* @param pd
* 查询、分页条件
* @return
* @throws Exception
*/
@RequestMapping(value = "/pageSearch")
public PageData pageSearch(@RequestBody PageData pd) throws Exception {
List<PageData> lists = null;
PageData pds = evaluateMapper.selectUserArea(pd);
if(pds != null){
pd.put("UA_AREA", pds.getString("UA_AREA"));
}
if (pd.getPageNumber() != 0) {
PageHelper.startPage(pd.getPageNumber(), pd.getPageSize());
}
lists = evaluateMapper.listPage(pd);
// 分页
pd = this.getPagingPd(lists);
// 结果集封装
return WebResult.requestSuccess(pd);
}
示例10: getLogs
import com.github.pagehelper.PageHelper; //导入依赖的package包/类
@Override
public List<LogVo> getLogs(int page, int limit) {
LOGGER.debug("Enter getLogs method:page={},linit={}",page,limit);
if (page <= 0) {
page = 1;
}
if (limit < 1 || limit > WebConst.MAX_POSTS) {
limit = 10;
}
LogVoExample logVoExample = new LogVoExample();
logVoExample.setOrderByClause("id desc");
PageHelper.startPage((page - 1) * limit, limit);
List<LogVo> logVos = logDao.selectByExample(logVoExample);
LOGGER.debug("Exit getLogs method");
return logVos;
}
示例11: businessSqlSessionFactory
import com.github.pagehelper.PageHelper; //导入依赖的package包/类
@Bean
@Primary
public SqlSessionFactory businessSqlSessionFactory(@Qualifier("businessDataSource") DruidDataSource businessDataSource) throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(businessDataSource);
//mybatis分页
Properties props = new Properties();
props.setProperty("dialect", "mysql");
props.setProperty("reasonable", "true");
props.setProperty("supportMethodsArguments", "true");
props.setProperty("returnPageInfo", "check");
props.setProperty("params", "count=countSql");
PageHelper pageHelper = new PageHelper();
pageHelper.setProperties(props);
//添加插件
sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sqlSessionFactoryBean.setMapperLocations(resolver.getResources(MAPPERXML_LOCATION));
return sqlSessionFactoryBean.getObject();
}
示例12: getTxs
import com.github.pagehelper.PageHelper; //导入依赖的package包/类
@Override
public List<TransactionLocalPo> getTxs(String address, int type, int pageNum, int pageSize) {
Searchable searchable = new Searchable();
if (type != 0) {
searchable.addCondition("b.type", SearchOperator.eq, type);
}
if (StringUtils.isNotBlank(address)) {
searchable.addCondition("a.address", SearchOperator.eq, address);
}
if (pageNum > 0 && pageSize > 0) {
PageHelper.startPage(pageNum, pageSize);
}
PageHelper.orderBy("block_height asc, create_time asc");
return getMapper().selectByAddress(searchable);
}
示例13: getRandomNodePoList
import com.github.pagehelper.PageHelper; //导入依赖的package包/类
@Override
public List<NodePo> getRandomNodePoList(int size, Set<String> keys) {
Searchable searchable = new Searchable();
PageHelper.startPage(1, 100);
PageHelper.orderBy("last_fail_time asc");
if (!keys.isEmpty()) {
searchable.addCondition("id", SearchOperator.notIn, keys);
}
searchable.addCondition("status", SearchOperator.eq, 0);
searchable.addCondition("last_fail_time", SearchOperator.lt, TimeService.currentTimeMillis() - TimeService.ONE_HOUR);
List<NodePo> list = getMapper().selectList(searchable);
if (list.size() <= size) {
return list;
} else {
Collections.shuffle(list);
}
return list.subList(0, size - 1);
}
示例14: getTxs
import com.github.pagehelper.PageHelper; //导入依赖的package包/类
@Override
public List<TransactionPo> getTxs(String address, int type, int pageNum, int pageSize) {
Searchable searchable = new Searchable();
if (type != 0) {
searchable.addCondition("b.type", SearchOperator.eq, type);
}
if (StringUtils.isNotBlank(address)) {
searchable.addCondition("a.address", SearchOperator.eq, address);
}
if (pageNum > 0 && pageSize > 0) {
PageHelper.startPage(pageNum, pageSize);
}
PageHelper.orderBy("block_height asc, create_time asc");
return getMapper().selectByAddress(searchable);
}
示例15: index
import com.github.pagehelper.PageHelper; //导入依赖的package包/类
@RequestMapping("/index")
public String index(@RequestParam(required = true, defaultValue = "1") Integer pageNum,
@RequestParam(required = true, defaultValue = "5") Integer pageSize, Model model) {
Blogger blogger = bloggerService.findByUsername("yuzhijun");// 因为只是自已是主人,所以直接传入名字
List<BlogType> blogTypeList = blogTypeService.getBlogTypeData();// 获取文章类型信息
List<Blog> blogArchiveList = blogService.getBlogArchive();// 获取文章归档信息
PageHelper.startPage(pageNum, pageSize);// 默认从第一页开始,每页五条
List<Blog> blogArticleList = blogService.getBlogArticle();// 获取文章主体信息
PageInfo<Blog> pageBlog = new PageInfo<Blog>(blogArticleList);// 将查出来的blogArticleList绑定到pageInfo中
System.out.println("个人资料: " + blogger);
System.out.println("文章类型: " + blogTypeList);
System.out.println("文章归档: " + blogArchiveList);
System.out.println("文章主体: " + blogArticleList);
model.addAttribute("blogger", blogger);// 存入个人资料
model.addAttribute("blogTypeList", blogTypeList);// 存入文章类型
model.addAttribute("blogArchiveList", blogArchiveList);// 存入文章归档
model.addAttribute("blogArticleList", blogArticleList);// 存入文章主题
model.addAttribute("pageBlog", pageBlog);// 设置pageBlog属性
return "index";
}