List<RoomInfo> fliterArea(@Param("idList")List<String> idList);
<select id="fliterArea" resultType="com.zlkj.business.space.management.api.domain.entity.RoomInfo"
parameterType="java.util.List">
select * from spam_room_info where is_del is FALSE
<if test="idList != null">
and
<foreach close=")" collection="idList" item="id" open="(" separator="or">
building_id = #{id}
</foreach>
</if>
</select>
这段XML代码是一个动态SQL标签<foreach>,用于遍历一个集合idList中的元素,并c。具体能如下:
close=")":指定闭合标签,这里是右括号")"。
collection="idList":指定要遍历的集合,这里是idList。
item="id":指定集合中每个元素的引用名称,这里是id。
open="(":指定开启动态SQL的标签,这里是左括号"("。
separator="or":指定分隔符,用于分隔每个遍历的元素,这里是逻辑运算符"or"。
building_id = #{id}:遍历时动态拼接的SQL条件,#{id}表示引用集合中当前元素的值。
综上所述,这段代码的作用是根据集合idList中的元素动态拼接多个SQL条件,形式为building_id = #{id},多个条件之间用"or"分隔。最终生成的SQL类似于(building_id = value1 or building_id = value2 or building_id = value3)。