<select id="queryByIDs" resultType="map">
select <include refid="aip_n_static_cols"/>, ${colstr}
from ${tableName}
where del_flag = 0 and id_bp_step = #{idBpStep} and id in
<foreach collection="ids" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
order by id
</select>
<!--第一种-->
<select id="getList" resultType="com.xs.sql.My">
SELECT *
FROM devcie
WHERE 1=1
<if test="ids != null and ids.size > 0">
AND id IN
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
<!--第二种-->
<select id="getList" resultType="com.xs.sql.My">
SELECT *
FROM devcie
WHERE 1=1
<if test="ids != null and ids.size > 0">
AND
<foreach collection="ids" item="item" open="id IN(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
<!--如果入参是一个逗号分隔的字符串比如"1,2,3,4",还可以简化写法,不用转成List,直接以字符串的形式传入即可-->
<select id="getList" resultType="com.xs.sql.My">
SELECT *
FROM devcie
WHERE 1=1
<if test="strIds != null and strIds != ''">
AND id IN
<foreach collection="strIds.split(',')" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
2.批量更新的时候
<!--第一种-->
<update id="updateList">
<foreach collection="deviceList" item="item" separator=";">
UPDATE device
SET
name = #{item.name},
no = #{item.no}
WHERE
id = #{item.id}
</foreach>
</update>
<!--第二种-->
<update id="updateList">
UPDATE device
SET
del_flag = 1
WHERE 1=1
AND id IN
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<!--第三种-->
<update id="deleteById">
update ${tableName} set DEL_FLAG = 1, deleteor = #{deleteor} where id in
<foreach collection="ids" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</update>