本文整理汇总了Java中com.github.pagehelper.PageInfo类的典型用法代码示例。如果您正苦于以下问题:Java PageInfo类的具体用法?Java PageInfo怎么用?Java PageInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PageInfo类属于com.github.pagehelper包,在下文中一共展示了PageInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOrderList
import com.github.pagehelper.PageInfo; //导入依赖的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: getProductList
import com.github.pagehelper.PageInfo; //导入依赖的package包/类
@Override
public ServerResponse<PageInfo> getProductList(int pageNum, int pageSize) {
//startPage--start
//填充自己的sql查询逻辑
//pageHelper-收尾
PageHelper.startPage(pageNum, pageSize);
List<Product> productList = productMapper.selectList();
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);
}
示例3: getItemSearchList
import com.github.pagehelper.PageInfo; //导入依赖的package包/类
@Override
public DataTablesResult getItemSearchList(int draw, int start, int length,int cid, String search,
String minDate, String maxDate, String orderCol, String orderDir) {
DataTablesResult result=new DataTablesResult();
//分页执行查询返回结果
PageHelper.startPage(start/length+1,length);
List<TbItem> list = tbItemMapper.selectItemByMultiCondition(cid,"%"+search+"%",minDate,maxDate,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;
}
示例4: getEmps
import com.github.pagehelper.PageInfo; //导入依赖的package包/类
/**
* 查询员工数据(分页查询)
* @return
*/
///@RequestMapping("/emps")
public String getEmps(@RequestParam(value="pn" ,defaultValue="1")Integer pn,Model model){ //传入当前页面,如果没有传则默认为1
//引入PageHelper分页插件
//在查询之前只需要调用,传入页码,以及分页每一页的大小
PageHelper.startPage(pn, 5);
//startPage后面紧跟的这个查询就是一个分页查询
List<Employee> emps =employeeService.getAll();
//使用pageInfo包装查询后的信息,只需要将pageinfo交给页面就行了。
//封装了详细的分页信息,包括有我们查询出来的数据,传入:连续显示的页数
PageInfo page=new PageInfo(emps,5); //5表示要连续显示的页数
model.addAttribute("PageInfo",page);
return "list";
}
示例5: getUserPageInfo
import com.github.pagehelper.PageInfo; //导入依赖的package包/类
@Override
public PageInfo<User> getUserPageInfo(int page, int limit) {
PageInfo<User> pageInfo = PageHelper.startPage(page, limit).doSelectPageInfo(new ISelect() {
@Override
public void doSelect() {
int offset = (page - 1) * limit;
RowBounds rowBounds = new RowBounds(offset, limit);
userMapper.selectByRowBounds(null, rowBounds);
}
});
logger.info("Page info ==> {}", pageInfo);
return pageInfo;
}
示例6: orderList
import com.github.pagehelper.PageInfo; //导入依赖的package包/类
@RequestMapping("list.do")
@ResponseBody
public ServerResponse<PageInfo> orderList(HttpSession session, @RequestParam(value = "pageNum",defaultValue = "1") int pageNum,
@RequestParam(value = "pageSize",defaultValue = "10")int pageSize){
User user = (User)session.getAttribute(Const.CURRENT_USER);
if(user == null){
return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"用户未登录,请登录管理员");
}
if(iUserService.checkUserRole(user).isSuccess()){
//填充我们增加产品的业务逻辑
return iOrderService.manageList(pageNum,pageSize);
}else{
return ServerResponse.createByError("无权限操作");
}
}
示例7: getItemList
import com.github.pagehelper.PageInfo; //导入依赖的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;
}
示例8: testPageHelper
import com.github.pagehelper.PageInfo; //导入依赖的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);
}
示例9: searchProduct
import com.github.pagehelper.PageInfo; //导入依赖的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.success(pageResult);
}
示例10: getCategorySecondaryList
import com.github.pagehelper.PageInfo; //导入依赖的package包/类
@Override
public Map<String, Object> getCategorySecondaryList(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.andParentIdEqualTo(0L);
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;
}
示例11: index
import com.github.pagehelper.PageInfo; //导入依赖的package包/类
@GetMapping(value = "")
public String index(@RequestParam(value = "page", defaultValue = "1") int page,
@RequestParam(value = "limit", defaultValue = "15") int limit, HttpServletRequest request) {
UserVo users = this.user(request);
CommentVoExample commentVoExample = new CommentVoExample();
commentVoExample.setOrderByClause("coid desc");
commentVoExample.createCriteria().andAuthorIdNotEqualTo(users.getUid());
PageInfo<CommentVo> commentsPaginator = commentsService.getCommentsWithPage(commentVoExample, page, limit);
request.setAttribute("comments", commentsPaginator);
return "admin/comment_list";
}
示例12: main
import com.github.pagehelper.PageInfo; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
SqlSession sqlSession = MybatisHelper.getSqlSession();
CountryMapper countryMapper = sqlSession.getMapper(CountryMapper.class);
/*rowBounds*/
RowBounds rowBounds = new RowBounds(2, 5);
/*Example*/
Example example = new Example(Country.class);
Example.Criteria criteria = example.createCriteria();
// criteria.andCountrycodeBetween("0", "ZZZZZZZZZZ");
// criteria.andIdBetween(0, 20);
List<Country> countries1 = countryMapper.selectByExample(example);
log.debug("countries1" + countries1.size());
List<Country> countries2 = countryMapper.selectByExampleAndRowBounds(example, rowBounds);
log.debug("countries2" + countries2.size());
PageInfo<Country> pageInfo = new PageInfo<>(countries1);
System.out.println("PageHelperTest.main() pageInfo :" + pageInfo.getSize());
}
示例13: findByProductName
import com.github.pagehelper.PageInfo; //导入依赖的package包/类
/**
* 门户:根据关键词查询商品(分页)
* @param keyword
* @param categoryId
* @return
*/
@Transactional(readOnly = true)
@Override
public ServerResponse<PageInfo<ProductListVo>> findByProductName(String keyword, Integer categoryId, Integer pageNum, Integer pageSize,String orderBy) {
//获取第1页,10条内容,默认查询总数count
PageHelper.startPage(pageNum, pageSize,orderBy);
List<ProductListVo> list = productMapper.findByProductName(keyword,categoryId);
if(list.size() > 0){
//用PageInfo对结果进行包装
PageInfo page = new PageInfo(list);
return ServerResponse.success(page);
}else {
return ServerResponse.error("参数错误");
}
}
示例14: categories
import com.github.pagehelper.PageInfo; //导入依赖的package包/类
@GetMapping(value = "category/{keyword}/{page}")
public String categories(HttpServletRequest request, @PathVariable String keyword,
@PathVariable int page, @RequestParam(value = "limit", defaultValue = "12") int limit) {
page = page < 0 || page > WebConst.MAX_PAGE ? 1 : page;
MetaDto metaDto = metaService.getMeta(Types.CATEGORY.getType(), keyword);
if (null == metaDto) {
return this.render_404();
}
PageInfo<ContentVo> contentsPaginator = contentService.getArticles(metaDto.getMid(), page, limit);
request.setAttribute("articles", contentsPaginator);
request.setAttribute("meta", metaDto);
request.setAttribute("type", "分类");
request.setAttribute("keyword", keyword);
return this.render("page-category");
}
示例15: page
import com.github.pagehelper.PageInfo; //导入依赖的package包/类
/**
* 自定义页面,如关于的页面
*/
@GetMapping(value = "/{pagename}")
public String page(@PathVariable String pagename, HttpServletRequest request) {
ContentVo contents = contentService.getContents(pagename);
if (null == contents) {
return this.render_404();
}
if (contents.getAllowComment()) {
String cp = request.getParameter("cp");
if (StringUtils.isBlank(cp)) {
cp = "1";
}
PageInfo<CommentBo> commentsPaginator = commentService.getComments(contents.getCid(), Integer.parseInt(cp), 6);
request.setAttribute("comments", commentsPaginator);
}
request.setAttribute("article", contents);
updateArticleHit(contents.getCid(), contents.getHits());
return this.render("page");
}