默認查詢7天的數據
<if test="startDate != null and startDate !='' ">
<![CDATA[AND a.use_date >= #{startDate}]]>
</if>
<if test="endDate != null and endDate !='' ">
<![CDATA[AND a.use_date < #{endDate}]]>
</if>
<if test='startDate == null and endDate == null' >
AND DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= a.use_date
</if>
默認查詢昨天的數據
<if test='startDate == null and endDate == null' >
AND TO_DAYS( NOW( ) ) - TO_DAYS( a.dept_kpi_date) = 1
</if>
參考:
if判斷參數等於某個值
<if test=' type == "1"'>....</if>