控制層Controller
@ApiOperation("分頁(yè)查詢gps設(shè)備歷史上傳記錄信息")
@ApiImplicitParams({
@ApiImplicitParam(name="pageNo",value="當(dāng)前頁(yè)",dataType="int", paramType = "query"),
@ApiImplicitParam(name="pageSize",value="分頁(yè)大小",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 之后,他會(huì)自動(dòng)對(duì)你這個(gè)方法分頁(yè)很強(qiáng)大的呀
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>