mybatis判断list非空
<select id="queryPavilionProductList" resultType="com.macro.mall.dto.MmsPavilionAssociatedProduct">
select
p.id as productId,
p.name , p.pic ,p.product_sn as productSn, p.product_category_id as productCategoryId, p.product_category_name as productCategoryName
from pms_product as p
where p.delete_status = 0
<if test="keyword != null and keyword != ''">
and (p.name like concat('%',#{keyword},'%') or p.product_sn like concat('%',#{keyword},'%'))
</if>
<if test="list != null and list.size() > 0">
and p.product_category_id in
<foreach collection="list" item="item" index="index" separator=",">
(#{item})
</foreach>
</if>
order by p.id
</select>
使用
<if test="list != null and list.size() > 0"></if>