Mapper层接口:
int updateCheckStatusHealthy(@Param("record")List<AppIndexPlate> paramMap,@Param("updateBy")Integer updateBy);
XML层:
<update id="updateCheckStatusHealthy">
<!-- params表示迭代集合的临时变量 -->
<foreach collection="record" item="params" index="index" open="" close="" separator=";">
update app_index_plate aip
<set>
aip.sort = #{params.sort},aip.update_by = #{updateBy},aip.update_time= now()
</set>
<where>
id = #{params.id}
</where>
</foreach>
</update>
注:如果properties文件连接数据源可能会因为mysql版本问题导致生成sql时报错,如果遇到报错信息加以下图片未打马的地方即可。
&allowMultiQueries=true
上图是运行成功的案例。。