当前位置:   article > 正文

springboot配置pagehelper

springboot配置pagehelper

1.maven

  1. <dependency>
  2. <groupId>com.github.pagehelper</groupId>
  3. <artifactId>pagehelper</artifactId>
  4. <version>4.1.3</version>
  5. </dependency>

2.在启动类里进行配置

  1. @Bean
  2. PageHelper pageHelper(){
  3. //分页插件
  4. PageHelper pageHelper = new PageHelper();
  5. Properties properties = new Properties();
  6. properties.setProperty("reasonable", "true");
  7. properties.setProperty("supportMethodsArguments", "true");
  8. properties.setProperty("returnPageInfo", "check");
  9. properties.setProperty("params", "count=countSql");
  10. pageHelper.setProperties(properties);
  11. //添加插件
  12. new SqlSessionFactoryBean().setPlugins(new Interceptor[]{pageHelper});
  13. return pageHelper;
  14. }

3.好了后就可以直接使用了

  1. @ApiOperation("条件查询库存")
  2. @PostMapping("/conditionQueryStock")
  3. public R conditionQueryStock(@RequestBody ConditionProStock conditionProStock) {
  4. PageHelper.startPage(conditionProStock.getCurrent(),conditionProStock.getSize());
  5. List<ProStock> proStocks = proStockService.conditionQueryStock(conditionProStock);
  6. PageInfo<ProStock> proStockPageInfo = new PageInfo<>(proStocks);
  7. return R.addSuccess(proStockPageInfo);
  8. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/87996
推荐阅读
相关标签
  

闽ICP备14008679号