分頁插件IPage

控制層Controller

@ApiOperation("分頁查詢gps設(shè)備歷史上傳記錄信息")
@ApiImplicitParams({
            @ApiImplicitParam(name="pageNo",value="當(dāng)前頁",dataType="int", paramType = "query"),
            @ApiImplicitParam(name="pageSize",value="分頁大小",dataType="int", paramType = "query"),
            @ApiImplicitParam(name="placeName",value="工棚名稱",dataType="String", paramType = "query")})
    @PostMapping("/findGpsRecordPage")
    public RestResponceBody<GpsRecordModel> findGpsRecordPage(@RequestParam(defaultValue = "1") int pageNo, @RequestParam(defaultValue = "15")  int pageSize, @RequestParam(required = false) String placeName){
        // 結(jié)論就是當(dāng)你的參數(shù)中加了  new Page 之后,他會自動對你這個方法分頁很強大的呀
        IPage<GpsRecordModel> gpsEntityIPage = gpsRecordService.findPage(new Page<GpsRecordModel>(pageNo, pageSize).addOrder(OrderItem.desc("a.create_time")),placeName);
        return new RestResponceBody<GpsRecordModel>(gpsEntityIPage) ;
    }

接口層IService

IPage<GpsRecordModel> findPage(Page<GpsRecordModel> page, String placeName);

服務(wù)層Service

 @Override
 public IPage<GpsRecordModel> findPage(Page<GpsRecordModel> page, String placeName) {
        return gpsRecordMapper.findPage(page,placeName);
    }

數(shù)據(jù)持久層Dao層

IPage<GpsRecordModel> findPage(Page<GpsRecordModel> page, @Param("placeName") String placeName);

XML文件

    <!-- 獲取gps記錄信息-->
    <select id="findPage" resultType="com.feige.gps.model.GpsRecordModel">
        select b.place_name,a.gps_no,d.rfid,d.pigeon_no,a.*,a.gps_status from feige_gps_record a
        left join feige_place_pigeon d on a.place_pigeon_id = d.id
        left join feige_place b on d.place_id = b.id
        <where>
            <if test="placeName != null and placeName != ''">
                b.place_name = #{placeName}
            </if>
        </where>
    </select>
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容