实体类
@Transient
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date reportDateStart;
@Transient
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date reportDateEnd;
前端传入时间

Mapper层
<if test="reportDateStart != null ">
AND cu.created <![CDATA[ >= ]]> CONCAT(#{reportDateStart}, ' 00:00:00')
</if>
<if test="reportDateEnd != null ">
AND cu.created <![CDATA[ < ]]> date_add(#{reportDateEnd}, INTERVAL 1 day)
</if>
这样得后台myabtis中查询得时间就为:2021-11-22 00:00:00~2021-11-22 23:59:59 了
发表评论