1.数据库日期转格式

DATE_FORMAT(measuring_time, '%Y-%m-%d') AS measuring_time,

 

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

2.日期大于小于

<if test="beginDate != null and beginDate != ''">
  AND DATE_FORMAT(measuring_time, '%Y-%m-%d') >= #{beginDate}
</if>
<if test="endDate != null and endDate != ''">
  AND DATE_FORMAT(measuring_time, '%Y-%m-%d') <= #{endDate}
</if>

 

3.foreach写法

 

<if test="healthStatuses != null">
  AND ha.health_status IN
  <foreach collection="healthStatuses" item="item" index="index" open="(" close=")" separator=",">
    #{item}
  </foreach>
</if>

 

 

4.模糊搜索

<if test="teamName != null and teamName != '' ">
  AND team_name LIKE CONCAT('%', #{teamName} ,'%')
</if>

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄