mybatis 的動(dòng)態(tài)sql

控制層就不多做解釋了
@Override
public List<TO7xzApp> findRecommendDownByCategoryChilrenNameList(String categoryChildrenName, int size, List<String> idList) {
Map<String, Object> queryMap = Maps.newHashMap();
queryMap.put("categoryChildrenName", categoryChildrenName);
queryMap.put("remark3", "1");
queryMap.put("size", size);
queryMap.put("idList", idList);
return mapper.findRecommendDownByCategoryChilrenNameList(queryMap);
}

Mapper文件
List<TO7xzApp> findRecommendDownByCategoryChilrenNameList(Map<String, Object> queryMap);
這里直接傳入一個(gè)map

再看xml文件
<select id="findHtmlStaticPageList" parameterType="hashmap" resultMap="BaseResultMap">
SELECT
CASE remark2 WHEN "soft" THEN "1" ELSE "2" END AS remark3,
<include refid="baseSql1" />
FROM
t_o7xz_app
<where>
<if test="categoryParentId != null and categoryParentId != ''">
and category_parent_id = #{categoryParentId}
</if>
<if test="id != null and id != ''">
and id LIKE CONCAT('%',#{id},'%')
</if>
<if test="appName != null and appName != ''">
and app_name LIKE CONCAT('%',#{appName},'%')
</if>
<if test="startTime != null and startTime != ''">
and create_time >= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
and create_time <= #{endTime}
</if>
<if test="audit != null and audit != ''">
and audit=#{audit}
</if>
</where>
ORDER BY create_time desc
</select>

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容