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