(1)map中字符串的使用
<if test="startInvokeStartTime != null">
and invoke_start_time >=
#{startInvokeStartTime,jdbcType=TIMESTAMP}
</if>
<if test="endInvokeStartTime != null">
<![CDATA[
and invoke_start_time <= #{endInvokeStartTime,jdbcType=TIMESTAMP}
]]>
</if>
(2)map对象的使用
<if test="interfaceInvokeLog != null">
<if test="interfaceInvokeLog.title != null and interfaceInvokeLog.title != '' ">
and title like concat('%',#{interfaceInvokeLog.title},'%')
</if>
<if
test="interfaceInvokeLog.startSys != null and interfaceInvokeLog.startSys != ''">
and start_sys like concat('%',#{interfaceInvokeLog.startSys},'%')
</if>
<if
test="interfaceInvokeLog.targetSys != null and interfaceInvokeLog.targetSys != '' ">
and target_sys like concat('%',#{targetSys},'%')
</if>
<if
test="interfaceInvokeLog.operatorMark != null and interfaceInvokeLog.operatorMark != '' ">
and operator_mark like
concat('%',#{interfaceInvokeLog.operatorMark},'%')
</if>
<if
test="interfaceInvokeLog.interfaceUrl != null and interfaceInvokeLog.interfaceUrl != '' ">
and interface_url like
concat('%',#{interfaceInvokeLog.interfaceUrl},'%')
</if>
</if>
说明:
(1)上文中标红处时map里面放的对象,用对象的属性值之前,首先要判断该对象是否存在,存在则继续判断对象的属性。
(2)这里的拼接一定要用#,而不是$
#是将传入的值当作字符串的形式
$是将传入的数据直接显示生成SQL语句