MyBatissql test如何判断Boolean

三种方式

<select id="queryAddress" resultType="com.caox.model.Address">
        select id, address, remark
        from address where
        1=1
        <if test="flag==true">
         and  address = #{address}
        </if>
    </select>
<update id="updateHaveNewComment">
        <choose>
            <when test="flag==true">
                UPDATE epc_subject_center s
                SET s.have_new_comment=1
                WHERE s.id=#{id}
            </when>
            <otherwise>
                UPDATE epc_subject_center s
                SET s.have_new_comment=0
                WHERE s.id=#{id}
            </otherwise>
        </choose>
    </update>
<update id="updateHaveNewComment">
        <choose>
            <when test="flag">
                UPDATE epc_subject_center s
                SET s.have_new_comment=1
                WHERE s.id=#{id}
            </when>
            <otherwise>
                UPDATE epc_subject_center s
                SET s.have_new_comment=0
                WHERE s.id=#{id}
            </otherwise>
        </choose>
    </update>

 

if标签判断boolean类型的写法

例子方法

在入参flag不为空的情况下直接判断

<if test="flag">
     AND order_status IN(1, 2, 3)
</if>
<if test="!flag">
     AND order_status IN(4, 5, 6)
</if>
<<choose>
   <when test="!flag">
           AND order_status  IN (4, 5, 6)
   </when>
   <otherwise>
           AND order_status  IN (1, 2, 3)
   </otherwise>
</choose>

以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程宝库

Feign是一个声明式的Web服务客户端,是面向接口编程的。也就是说使用Feign,只需要创建一个接口并使用注解方式配置它,就可以完成对微服务提供方的接口绑定。在使用RestTempl ...