虽然Mybatis-plus也提供了不错的批量修改的方法,但是我第一次使用的就是Mybatis的,用起来比较顺手一点
直接上代码
Mapper
int updateGtwolist(List<GovernmentOverseasTable2> gtwolist);
Mapper.xml
<update id="updateGtwolist" parameterType="java.util.List">
update government_overseas_table2
<trim prefix="set" suffixOverrides=",">
<trim prefix="is_on_time=case" suffix="end,">
<foreach collection="list" item="item" index="index">
<if test="item.isOnTime !=null and item.isOnTime != ''">
when id=#{item.id} then #{item.isOnTime}
</if>
</foreach>
</trim>
<trim prefix="remarks=case" suffix="end">
<foreach collection="list" item="item" index="index">
<if test="item.remarks !=null and item.remarks != ''">
when id=#{item.id} then #{item.remarks}