mybatis xml 對映檔案 sql-include 的用法
阿新 • • 發佈:2021-12-09
<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" />