Java Code Examples for com.github.pagehelper.PageHelper#startPage()
The following examples show how to use
com.github.pagehelper.PageHelper#startPage() .
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: TestPlanController.java From seppb with MIT License | 6 votes |
@RequestMapping(value = "/plan/query", method = RequestMethod.POST) public PageInfo<TestPlan> testPlanQuery(HttpServletRequest request) { Map<String, Object> dataMap = new HashMap<>(); dataMap.put(CommonParameter.PRODUCT_ID, ParameterThreadLocal.getProductId()); dataMap.put(CommonParameter.REL_ID, request.getParameter(CommonParameter.REL_ID)); dataMap.put(CommonParameter.ID, request.getParameter("planId")); dataMap.put("planType", request.getParameter("planType")); dataMap.put("planStatus", request.getParameter("planStatus")); dataMap.put(CommonParameter.RESPONSER, request.getParameter(CommonParameter.RESPONSER)); if (!StringUtils.isEmpty(request.getParameter("planedDateBegin"))) { dataMap.put("planedDateBegin", request.getParameter("planedDateBegin") + " 00:00:00"); } if (!StringUtils.isEmpty(request.getParameter("planedDateEnd"))) { dataMap.put("planedDateEnd", request.getParameter("planedDateEnd") + " 23:59:59"); } PageHelper.startPage(ParameterThreadLocal.getPageNum(), ParameterThreadLocal.getPageSize()); List<TestPlan> list = testPlanService.testPlanQuery(dataMap); PageInfo<TestPlan> pageInfo = new PageInfo<>(list); return pageInfo; }
Example 2
Source File: LitemallOrderServiceImpl.java From BigDataPlatform with GNU General Public License v3.0 | 6 votes |
public List<LitemallOrder> querySelective(Integer userId, String orderSn, List<Short> orderStatusArray, Integer page, Integer limit, String sort, String order) { LitemallOrderExample example = new LitemallOrderExample(); LitemallOrderExample.Criteria criteria = example.createCriteria(); if (userId != null) { criteria.andUserIdEqualTo(userId); } if (!StringUtils.isEmpty(orderSn)) { criteria.andOrderSnEqualTo(orderSn); } if (orderStatusArray != null && orderStatusArray.size() != 0) { criteria.andOrderStatusIn(orderStatusArray); } criteria.andDeletedEqualTo(false); if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) { example.setOrderByClause(sort + " " + order); } PageHelper.startPage(page, limit); return litemallOrderMapper.selectByExample(example); }
Example 3
Source File: LitemallFeedbackService.java From mall with MIT License | 6 votes |
public List<LitemallFeedback> querySelective(Integer userId, String username, Integer page, Integer limit, String sort, String order) { LitemallFeedbackExample example = new LitemallFeedbackExample(); LitemallFeedbackExample.Criteria criteria = example.createCriteria(); if (userId != null) { criteria.andUserIdEqualTo(userId); } if (!StringUtils.isEmpty(username)) { criteria.andUsernameLike("%" + username + "%"); } criteria.andDeletedEqualTo(false); if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) { example.setOrderByClause(sort + " " + order); } PageHelper.startPage(page, limit); return feedbackMapper.selectByExample(example); }
Example 4
Source File: PmsProductCategoryServiceImpl.java From BigDataPlatform with GNU General Public License v3.0 | 5 votes |
@Override public List<PmsProductCategory> getList(Long parentId, Integer pageSize, Integer pageNum) { PageHelper.startPage(pageNum, pageSize); PmsProductCategoryExample example = new PmsProductCategoryExample(); example.setOrderByClause("sort desc"); example.createCriteria().andParentIdEqualTo(parentId); return productCategoryMapper.selectByExample(example); }
Example 5
Source File: BaseServiceImpl.java From lion with Apache License 2.0 | 5 votes |
/** * 分页查询 * * @param pageNum 页码值 * @param pageSize 每页大小 * @param orderBy 排序字段 * @return PageInfo 分页对象 */ @Override public PageInfo<T> page(int pageNum, int pageSize, String orderBy) { if (null == orderBy) { PageHelper.startPage(pageNum, pageSize); } else { PageHelper.startPage(pageNum, pageSize, orderBy); } List<T> list = list(); PageInfo<T> pageInfo = new PageInfo<>(list); return pageInfo; }
Example 6
Source File: LitemallGoodsService.java From mall with MIT License | 5 votes |
/** * 获取新品上市 * * @param offset * @param limit * @return */ public List<LitemallGoods> queryByNew(int offset, int limit) { LitemallGoodsExample example = new LitemallGoodsExample(); example.or().andIsNewEqualTo(true).andIsOnSaleEqualTo(true).andDeletedEqualTo(false); example.setOrderByClause("add_time desc"); PageHelper.startPage(offset, limit); return goodsMapper.selectByExampleSelective(example, columns); }
Example 7
Source File: GradeController.java From sms-ssm with MIT License | 5 votes |
/** * @description: 分页查询:根据年级名称获取指定/所有年级信息列表 * @param: page * @param: rows * @param: gradename * @date: 2019-06-15 1:14 PM * @return: java.util.Map<java.lang.String, java.lang.Object> */ @PostMapping("/getGradeList") @ResponseBody public Map<String, Object> getGradeList(Integer page, Integer rows, String gradename) { //注意:使用Java Bean传递gradename,防止以下异常 ! //org.springframework.web.util.NestedServletException: Request processing failed; // nested exception is org.mybatis.spring.MyBatisSystemException: // nested exception is org.apache.ibatis.reflection.ReflectionException: // There is no getter for property named 'name' in 'class java.lang.String' Grade grade = new Grade(); grade.setName(gradename); //设置每页的记录数 PageHelper.startPage(page, rows); //根据年级名称获取指定或全部年级信息列表 List<Grade> list = gradeService.selectList(grade); //封装信息列表 PageInfo<Grade> pageInfo = new PageInfo<>(list); //获取总记录数 long total = pageInfo.getTotal(); //获取当前页数据列表 List<Grade> gradeList = pageInfo.getList(); //存储数据对象 result.put("total", total); result.put("rows", gradeList); return result; }
Example 8
Source File: RoleController.java From bootshiro with MIT License | 5 votes |
@SuppressWarnings("unchecked") @ApiOperation(value = "获取角色(roleId)所被授权的API资源") @GetMapping("api/{roleId}/{currentPage}/{pageSize}") public Message getRestApiExtendByRoleId(@PathVariable Integer roleId, @PathVariable Integer currentPage, @PathVariable Integer pageSize) { PageHelper.startPage(currentPage, pageSize); List<AuthResource> authResources = resourceService.getAuthorityApisByRoleId(roleId); PageInfo pageInfo = new PageInfo(authResources); return new Message().ok(6666, "return api success").addData("data", pageInfo); }
Example 9
Source File: LitemallBrandServiceImpl.java From BigDataPlatform with GNU General Public License v3.0 | 5 votes |
public List<LitemallBrand> query(Integer page, Integer limit, String sort, String order) { LitemallBrandExample example = new LitemallBrandExample(); example.or().andDeletedEqualTo(false); if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) { example.setOrderByClause(sort + " " + order); } PageHelper.startPage(page, limit); return brandMapper.selectByExampleSelective(example, columns); }
Example 10
Source File: MessageController.java From feiqu-opensource with Apache License 2.0 | 5 votes |
@GetMapping("/dialog/{userId}") public String msgs(HttpServletRequest request, HttpServletResponse response, @RequestParam(defaultValue = "0") Integer pageIndex, @PathVariable Integer userId, @RequestParam(defaultValue = "desc") String order) { FqUserCache user = webUtil.currentUser(request, response); if(user == null){ return "redirect:/u/login?redirectSuccessUrl="+CommonConstant.DOMAIN_URL+request.getRequestURI(); } if(!OrderEnum.ASC.getCode().equals(order) && !OrderEnum.DESC.getCode().equals(order)){ return "redirect:/message/dialogs"; } int myUserId = user.getId(),friendUserId = userId; FqUserExample userExample = new FqUserExample(); userExample.createCriteria().andIdEqualTo(userId); int userCount = fqUserService.countByExample(userExample); //userId -1 代表系统消息 if(userId != -1 && userCount <= 0){ return "redirect:/message/dialogs"; } PageHelper.startPage(pageIndex, CommonConstant.DEAULT_PAGE_SIZE); List<MessageUserDetail> messages = messageService.selectDialogDetail(myUserId,friendUserId, order); // List<MessageUserDetail> messages = messageService.selectMyMsgsByMessage(messageExample); PageInfo page = new PageInfo(messages); request.setAttribute("postUserId", userId); request.setAttribute("count", page.getTotal()); request.setAttribute("messages", messages); request.setAttribute("pageIndex", pageIndex); request.setAttribute("pageSize", CommonConstant.DEAULT_PAGE_SIZE); return "/user/msgs.html"; }
Example 11
Source File: FqNewsController.java From feiqu-opensource with Apache License 2.0 | 5 votes |
/** * 跳转到FqNews首页 */ @RequestMapping("") public String index(@RequestParam(defaultValue = "desc") String order, Model model, @RequestParam(defaultValue = "1") Integer pageIndex) { PageHelper.startPage(pageIndex,20); FqNewsExample fqNewsExample = new FqNewsExample(); fqNewsExample.setOrderByClause("gmt_create "+order); List<FqNews> fqNews = fqNewsService.selectByExample(fqNewsExample); model.addAttribute("fqNews",fqNews); PageInfo page = new PageInfo(fqNews); model.addAttribute("pageIndex",pageIndex); model.addAttribute("pageSize",20);//文章放多点好,感觉,要不然老是需要翻页 model.addAttribute("count",page.getTotal()); return "/news/index.html"; }
Example 12
Source File: MdcProductCategoryQueryFeignClient.java From paascloud-master with Apache License 2.0 | 5 votes |
/** * 获取商品列表信息. * * @param productReqDto the product req dto * * @return the product list */ @Override @ApiOperation(httpMethod = "POST", value = "获取商品列表信息") public Wrapper<PageInfo> getProductList(@RequestBody ProductReqDto productReqDto) { logger.info("获取商品列表信息. productReqDto={}", productReqDto); Long categoryId = productReqDto.getCategoryId(); String keyword = productReqDto.getKeyword(); Integer pageNum = productReqDto.getPageNum(); Integer pageSize = productReqDto.getPageSize(); String orderBy = productReqDto.getOrderBy(); if (StringUtils.isBlank(keyword) && null == categoryId) { return WrapMapper.ok(new PageInfo()); } List<Long> categoryIdList = Lists.newArrayList(); if (categoryId != null) { MdcProductCategory category = mdcProductCategoryService.selectByKey(categoryId); if (category == null && StringUtils.isBlank(keyword)) { // 没有该分类,并且还没有关键字,这个时候返回一个空的结果集,不报错 PageHelper.startPage(pageNum, pageSize); return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, new PageInfo()); } categoryIdList = mdcProductCategoryService.selectCategoryAndChildrenById(categoryId); } PageHelper.startPage(pageNum, pageSize); //排序处理 List<MdcProduct> productList = mdcProductService.selectByNameAndCategoryIds(StringUtils.isBlank(keyword) ? null : keyword, PublicUtil.isEmpty(categoryIdList) ? null : categoryIdList, orderBy); List<ProductDto> productListVoList = Lists.newArrayList(); for (MdcProduct product : productList) { ProductDto productListVo = assembleProductListVo(product); String url = mdcProductService.getMainImage(product.getId()); productListVo.setMainImage(url); productListVoList.add(productListVo); } return PublicUtil.isNotEmpty(productListVoList) ? WrapMapper.ok(new PageInfo<>(productListVoList)) : WrapMapper.ok(); }
Example 13
Source File: ContentServiceImpl.java From BigDataPlatform with GNU General Public License v3.0 | 5 votes |
@Override public AllGoodsResult getAllProduct(int page, int size, String sort, Long cid, int priceGt, int priceLte) { AllGoodsResult allGoodsResult=new AllGoodsResult(); List<Product> list=new ArrayList<>(); //分页执行查询返回结果 if(page<=0) { page = 1; } PageHelper.startPage(page,size); //判断条件 String orderCol="created"; String orderDir="desc"; if(sort.equals("1")){ orderCol="price"; orderDir="asc"; }else if(sort.equals("-1")){ orderCol="price"; orderDir="desc"; }else{ orderCol="created"; orderDir="desc"; } List<TbItem> tbItemList = tbItemMapper.selectItemFront(cid,orderCol,orderDir,priceGt,priceLte); PageInfo<TbItem> pageInfo=new PageInfo<>(tbItemList); for(TbItem tbItem:tbItemList){ Product product= DtoUtil.TbItem2Product(tbItem); list.add(product); } allGoodsResult.setData(list); allGoodsResult.setTotal((int) pageInfo.getTotal()); return allGoodsResult; }
Example 14
Source File: BaseService.java From luckwheel with Apache License 2.0 | 5 votes |
/** * 通过字段查询依托通用方法 * @param pageNo 起始页 * @param pageSize * @param where * @param orderByField * @param fields * @return */ private List<T> queryByFiledBase(Integer pageNo,Integer pageSize,Sqls where,String orderByField, String ...fields){ Example.Builder builder=null; if(null==fields||fields.length==0){ //查询所有 builder = Example.builder(getTypeArguement()); }else{ //查询指定字段 builder= Example.builder(getTypeArguement()) .select(fields); } if(where!=null){ builder=builder.where(where); } if(orderByField!=null){ builder= builder .orderByDesc(orderByField); } Example example=builder.build(); if(pageNo!=null&&pageSize!=null) { PageHelper.startPage(pageNo, pageSize); //分页插件 } List list = getMapper().selectByExample(example); return list; }
Example 15
Source File: RoleController.java From bootshiro with MIT License | 5 votes |
@SuppressWarnings("unchecked") @ApiOperation(value = "获取角色(roleId)所被授权的menu资源") @GetMapping("menu/{roleId}/{currentPage}/{pageSize}") public Message getMenusByRoleId(@PathVariable Integer roleId, @PathVariable Integer currentPage, @PathVariable Integer pageSize) { PageHelper.startPage(currentPage, pageSize); List<AuthResource> authResources = resourceService.getAuthorityMenusByRoleId(roleId); PageInfo pageInfo = new PageInfo(authResources); return new Message().ok(6666, "return api success").addData("data", pageInfo); }
Example 16
Source File: BrowserService.java From server with MIT License | 5 votes |
public Response list(Browser browser, PageRequest pageRequest) { boolean needPaging = pageRequest.needPaging(); if (needPaging) { PageHelper.startPage(pageRequest.getPageNum(), pageRequest.getPageSize()); } List<Browser> browsers = selectByBrowser(browser); if (needPaging) { long total = Page.getTotal(browsers); return Response.success(Page.build(browsers, total)); } else { return Response.success(browsers); } }
Example 17
Source File: FuzzQueryController.java From seppb with MIT License | 5 votes |
@RequestMapping(value = "/fuzz/problem_query", method = RequestMethod.POST) public PageInfo<Problem> problemQuery(HttpServletRequest request, @RequestParam(value = "searchText") String searchText) { Map<String, String> dataMap = new HashMap<>(); dataMap.put(CommonParameter.PRODUCT_ID, String.valueOf(ParameterThreadLocal.getProductId())); dataMap.put("searchText", searchText); int pageNum = ParameterThreadLocal.getPageNum(); int pageSize = ParameterThreadLocal.getPageSize(); PageHelper.startPage(pageNum, pageSize); List<Problem> list = fuzzQueryService.problemQuery(dataMap); PageInfo<Problem> pageInfo = new PageInfo<>(list); return pageInfo; }
Example 18
Source File: SecondCacheTest.java From Mybatis-PageHelper with MIT License | 5 votes |
@Test public void test3() { SqlSession sqlSession = MybatisHelper.getSqlSession(); UserMapper userMapper = sqlSession.getMapper(UserMapper.class); try { //获取第1页,10条内容,默认查询总数count PageHelper.startPage(1, 10); List<User> list = userMapper.selectGreterThanId(10); assertEquals(10, list.size()); } finally { sqlSession.close(); } }
Example 19
Source File: NamespacesRepositoryImpl.java From pulsar-manager with Apache License 2.0 | 4 votes |
@Override public Page<NamespaceEntity> findByNamespace(Integer pageNum, Integer pageSize, String namespace) { PageHelper.startPage(pageNum, pageSize); Page<NamespaceEntity> namespacesEntities = namespacesMapper.findByNamespace(namespace); return namespacesEntities; }
Example 20
Source File: EmployeeController.java From ManagementSystem with Apache License 2.0 | 3 votes |
/** * ajax请求方式 * 导入jackson包 * @param pn * @return */ @RequestMapping("/emps") @ResponseBody public Msg getEmpsWithJson(@RequestParam(value = "pn",defaultValue = "1") Integer pn){ //1.引入pageHelper //2.mybatis-config注册 //3.查询之前只需要调用,传入页码,每页的大小 PageHelper.startPage(pn,5); //4.startPage后面紧跟的查询是一个分页查询 List<Employee> employeeList = iEmployeeService.getAll(); //5.使用pageInfo包装查询后的结果,传入连续显示的页数 PageInfo pageInfo = new PageInfo(employeeList,5); //6.把pageInfo交给页面 //7.分装了详细的分页信息,包括查询出来的信息 return Msg.success().add("pageInfo",pageInfo); }