mybatis xml 映射文件 sql-include 的用法
<sql id = "Condition_List"> <!-- 根据资源商类型查询 --> <if test="query.partnerType != null" > and a.type = #{query.partnerType} </if> <!-- 根据所在地查询 --> <if test="query.areaCode != null" > and a.area_code = #{query.areaCode} </if> <!-- 根据主营品牌ID查询 --> <if test="query.brandIds != null" > and LOCATE(#{query.brandIds},a.car_brand_id)>0 </if> <!-- 根据关键字查询 合作商名称 --> <if test="query.key != null" > and a.name like concat('%',#{query.key},'%') </if> <!-- 根据创建时间查询 --> <if test="query.createTime != null" > and a.create_time between #{query.createTime[0]} and #{query.createTime[1]} </if> </sql>
<include refid="Condition_List" />