當前位置: 首頁>>代碼示例>>Java>>正文


Java PageHelper類代碼示例

本文整理匯總了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);
}
 
開發者ID:wangshufu,項目名稱:mmall,代碼行數:9,代碼來源:OrderServiceImpl.java

示例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);
}
 
開發者ID:jeikerxiao,項目名稱:X-mall,代碼行數:10,代碼來源:OrderServiceImpl.java

示例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);
}
 
開發者ID:jeikerxiao,項目名稱:X-mall,代碼行數:17,代碼來源:ProductServiceImpl.java

示例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);
	
	
}
 
開發者ID:ChenXcc,項目名稱:taotao-shop,代碼行數:24,代碼來源:TestPageHelper.java

示例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;
}
 
開發者ID:xubinux,項目名稱:xbin-store,代碼行數:23,代碼來源:ContentServiceImpl.java

示例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;
}
 
開發者ID:xubinux,項目名稱:xbin-store,代碼行數:24,代碼來源:ContentServiceImpl.java

示例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());

}
 
開發者ID:MiniPa,項目名稱:cjs_ssms,代碼行數:22,代碼來源:PageMapperTest.java

示例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;
}
 
開發者ID:Exrick,項目名稱:xmall,代碼行數:19,代碼來源:ItemServiceImpl.java

示例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);
}
 
開發者ID:noseparte,項目名稱:Spring-Boot-Server,代碼行數:25,代碼來源:EvaluateRestful.java

示例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;
}
 
開發者ID:ZHENFENG13,項目名稱:My-Blog,代碼行數:17,代碼來源:LogServiceImpl.java

示例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();
}
 
開發者ID:DomKing,項目名稱:springbootWeb,代碼行數:21,代碼來源:BusinessDatabaseConfig.java

示例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);
}
 
開發者ID:nuls-io,項目名稱:nuls,代碼行數:18,代碼來源:TransactionLocalDaoImpl.java

示例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);
}
 
開發者ID:nuls-io,項目名稱:nuls,代碼行數:20,代碼來源:NodeDaoImpl.java

示例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);
}
 
開發者ID:nuls-io,項目名稱:nuls,代碼行數:18,代碼來源:TransactionDaoImpl.java

示例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";
}
 
開發者ID:shinyjunjun,項目名稱:myblog,代碼行數:25,代碼來源:IndexController.java


注:本文中的com.github.pagehelper.PageHelper類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。