1. 程式人生 > >Mybatis plus分頁查詢

Mybatis plus分頁查詢

EntityWrapper會把每個引數和entity裡面進行匹配 

  public PageUtils queryUnProcesEquip(Map<String, Object> params) {

        //新建wrapper物件
        Wrapper<EquipmentConfigEntity> wrapper= new EntityWrapper<>();
        //放入引數
        wrapper.allEq(params);
        //帶參分頁查詢
        Page<EquipmentConfigEntity> page = this.selectPage(
                new Query<EquipmentConfigEntity>(params).getPage(),
              wrapper
        );

        return new PageUtils(page);
    }

Wrapper不會,分頁查詢的時候用Wrapper普通查詢可以用Wrapper也可以用EntityWrapper

 //新建wrapper物件
        Wrapper<EquipmentConfigEntity> wrapper = new Wrapper<EquipmentConfigEntity>() {
            @Override
            public String getSqlSegment() {
                return null;
            }
        };


        //放入引數
        wrapper.allEq(params);
        //帶參分頁查詢
        Page<EquipmentConfigEntity> page = this.selectPage(
                new Query<EquipmentConfigEntity>(params).getPage(),
              wrapper
        );

        return new PageUtils(page);