Loading

mybatis xml 中 trim 多余的符号

<if test="(mac != null and mac != '') or (roomNo != null and roomNo != '') or (bedNo != null and bedNo!= '') or (kinds != null and kinds.size > 0)">
    and
    <trim prefix="(" prefixOverrides="or" suffix=")">
        <if test="mac != null and mac != ''">
            or device.mac like concat('%',#{mac},'%')
        </if>
        <if test="roomNo != null and roomNo != ''">
            or room.no like concat('%', #{roomNo}, '%')
        </if>
        <if test="bedNo != null and bedNo!= ''">
            or bed.no like concat('%', #{bedNo}, '%')
        </if>
        <if test="kinds != null and kinds.size > 0">
            or device.kind in
            <foreach collection="kinds" item="kind" index="index" open="(" close=")" separator=",">
                #{kind}
            </foreach>
        </if>
    </trim>
</if>
posted @ 2021-07-23 10:50  myEsn2E9  阅读(94)  评论(0编辑  收藏  举报