【记录】Mybatis-plus中Page插件 快速进行分页操作
使用mybatis-plus 封装好的Page插件,可以很方便的帮助我们进行查询分页,不用再写过多冗余代码,强烈推荐
以下是本人使用的例子:
pom依赖
<dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-generator</artifactId> </dependency>
Bo实体
@Data public class ComplaintCompBo { @ApiModelProperty(value = "车牌号",example = "sss") private String plateNum; @ApiModelProperty(value = "驾驶员姓名",example = "XXXX") private String driverName; @ApiModelProperty(value = "投诉开始时间",example = "2020-06-08 13:00:00") private String complaintBeginTime; @ApiModelProperty(value = "投诉结束时间",example = "2020-06-08 14:00:00") private String complaintEndTime; @ApiModelProperty(value = "企业ID",example = "1111111111") private String companyId; @ApiModelProperty(value ="当前页数" ,example = "1", required = true) private Integer current; @ApiModelProperty(value ="每页条数" ,example = "10", required = true) private Integer size; }
serviceImpl接口
@Override public HttpResult<Page<ComplaintCompDto>> pageRelationComp(ComplaintCompBo complaintCompBo) { Page<ComplaintCompDto> page = new Page(complaintCompBo.getCurrent(),complaintCompBo.getSize()); Page<ComplaintCompDto> pageList = mapper.getPassengerComplaintCompList(page,complaintCompBo); return HttpResult.success(pageList); }
Mapper 接口方法
Page<ComplaintCompDto> getPassengerComplaintCompList(Page<ComplaintCompDto> page,@Param("condition") ComplaintCompBo complaintCompBo);
关联的查询语句
<!--乘客投诉信息查询与企业关联--> <select id="getPassengerComplaintCompList" resultType="com.xxx.ComplaintCompDto"> SELECT t1.* FROM ct_taxi_rh_pers_opemng_sti_passager_complaint t1 ORDER BY t1.complaint_time desc </select>