• Mybatisplus分页插件的使用


    一、加依赖:

    1   <dependency>
    2             <groupId>com.baomidou</groupId>
    3             <artifactId>mybatis-plus</artifactId>
    4             <version>${mybatis-plus.version}</version>
    5   </dependency>

    二、加配置:

    1  <plugins>
    2         <!-- 分页查询插件 -->
    3         <plugin interceptor="com.baomidou.mybatisplus.plugins.PaginationInterceptor">
    4             <property name="dialectType" value="mysql" />
    5         </plugin>
    6  </plugins>

     三、controller使用:

    1     @PostMapping("orderlist.api")
    2     @ApiOperation(value = "分页查询", produces = MediaType.APPLICATION_JSON_VALUE)
    3     public Object memberOrderlist(@RequestBody DriverDto dto, HttpServletRequest request, HttpServletResponse response) {
    4       Page<BizOrderlist> page = new Page<BizOrderlist>(dto.getPage() == null ? 1 : dto.getPage() , dto.getPageSize() == null ? 15 : dto.getPageSize()); //初始化分页条数,如果传入的值为空在默认第一页,15条。
    5       Parameter orderparameter = new Parameter(getService(), "getOrderlist").setParam(page,params); //在servie中获取list,传递分页Page和查询参数
    6       Page<BizOrderlist>  orderList = (Page<BizOrderlist>) provider.execute(orderparameter).getResult();    

    四、service中使用:

    1  public Page<BizOrderlist> getOrderlist(Page<BizOrderlist> page,Map<String, Object> params) {
    2         
    3         List<BizOrderlist> orderlist = (List<BizOrderlist>) ((OrderListMapper) mapper).getOrderList(page,param1,params2,params3);
    4         page = page.setRecords(orderlist);  //查出的list调用setRecords
    5         return page;

    五、Mapper:

    1   public interface OrderListMapper extends BaseMapper<BizOrderlist> {
    2 
    3     List<BizOrderlist> getOrderList(Pagination  page,@Param("param1") Double param1...........);
  • 相关阅读:
    ExtJS 4.0 改善Ext.grid.plugin.RowEditing (重构,v1.4版本,20110911)
    GeoServer源码解析和扩展 (四)文件系统
    Ext蒙板效果
    Ext Grid表格的自动宽度及高度的实现
    Extjs4用RowEditing对数据进行增加,修改
    ExtJs4.0 Grid分頁詳解
    canvas的处理图片功能
    cookie的设置和读取
    html5的canvas知识
    初学jquery mobile
  • 原文地址:https://www.cnblogs.com/laowangc/p/8877659.html
Copyright © 2020-2023  润新知