控制层Controller
@ApiOperation("分页查询gps设备历史上传记录信息")
@ApiImplicitParams({
@ApiImplicitParam(name="pageNo",value="当前页",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){
// 结论就是当你的参数中加了 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);
服务层Service
@Override
public IPage<GpsRecordModel> findPage(Page<GpsRecordModel> page, String placeName) {
return gpsRecordMapper.findPage(page,placeName);
}
数据持久层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>