美文网首页
分页插件IPage

分页插件IPage

作者: 致HTC | 来源:发表于2019-11-06 16:33 被阅读0次

控制层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>

相关文章

网友评论

      本文标题:分页插件IPage

      本文链接:https://www.haomeiwen.com/subject/qunubctx.html