接口函数定义:

List<Fastswitch> selectByExample(@Param("class1") Class1 class1, @Param("on") Byte on);

配置文件中:

<select id="selectByExample" parameterType="map" resultType="java.util.Map">
    SELECT
    f.id, f.old_ruleId, f.new_ruleId, f.field1, f.field2, f.create_time, f.update_time
    from fastSwitch f
    LEFT JOIN rule r
    ON f.old_ruleId=r.id
    where 1=1
    <if test="class1.id != null">
        and f.id = #{class1.id}
    </if>
    <if test="class1.oldRuleid != null">
        and f.old_ruleId = #{class1.oldRuleid,jdbcType=INTEGER}
    </if>
    <if test="class1.newRuleid != null">
        and f.new_ruleId = #{class1.newRuleid,jdbcType=INTEGER}
    </if>
    <if test="class1.field1 != null">
        and f.field1 = #{class1.field1,jdbcType=VARCHAR}
    </if>
    <if test="class1.field2 != null">
        and f.field2 = #{class1.field2,jdbcType=VARCHAR}
    </if>
    <if test="fastswitch.createTime != null">
        and f.create_time = #{fastswitch.createTime,jdbcType=TIMESTAMP}
    </if>
    <if test="class1.updateTime != null">
        and f.update_time = #{class1.updateTime,jdbcType=TIMESTAMP},
    </if>
    AND r.nodata=#{on}
    ORDER BY create_time DESC
</select>
01-29 13:08