您的位置:首页 > 数据库

MyBatis动态SQL使用,传入参数Map中的Key判断

2018-02-28 10:29 567 查看
当使用Map做为参数时,可以用_parameter.containsKey(变量名)来判断map中是否包含有些变量:[html] view plaincopy



<select id="selectRule" parameterType="Map" resultType="com.ourangel.weixin.domain.Rule">  
    SELECT ruleId,msgType,event,respId,reqValue,firstRespId,createDate,yn  
    FROM oal_tb_rule  
    WHERE yn = 1  
    <if test="_parameter.containsKey('msgType')">  
        AND msgType = #{msgType,jdbcType=VARCHAR})  
    </if>  
    <if test="_parameter.containsKey('event')">  
        AND event = #{event,jdbcType=VARCHAR})  
    </if>  
</select> 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: