<update id="updateKszdy" parameterType="com.jykj.yxxt.api.model.zsgl.importksxxb.Ksxxb">
update t_ks_ksxxb
set
<foreach collection="list" item="item" index="index"
separator=" " open="" close="">
<if test="item.zdy1!=null">
<if test="index == 0">
zdy1 = case ksid
</if>
when #{item.ksid} then #{item.zdy1}
<if test="index==list.size()-1">
end
</if>
</if>
</foreach>
<foreach collection="list" item="item" index="index"
separator=" " open="" close="">
<if test="item.zdy1!=null and item.zdy2!=null">
<if test="index == 0">
,zdy2= case ksid
</if>
when #{item.ksid} then #{item.zdy2}
<if test="index==list.size()-1">
end
</if>
</if>
<if test="item.zdy1==null and item.zdy2!=null">
<if test="index == 0">
zdy2= case ksid
</if>
when #{item.ksid} then #{item.zdy2}
<if test="index==list.size()-1">
end
</if>
</if>
</foreach>
<foreach collection="list" item="item" index="index"
separator=" " open="" close="">
<if test="(item.zdy1!=null or item.zdy2!=null) and item.zdy3!=null">
<if test="index == 0">
,zdy3= case ksid
</if>
when #{item.ksid} then #{item.zdy3}
<if test="index==list.size()-1">
end
</if>
</if>
<if test="item.zdy1==null and item.zdy2==null and item.zdy3!=null">
<if test="index == 0">
zdy3= case ksid
</if>
when #{item.ksid} then #{item.zdy3}
<if test="index==list.size()-1">
end
</if>
</if>
</foreach>
where ksid in
<foreach collection="list" index="index" item="item"
separator="," open="(" close=")">
#{item.ksid,jdbcType=BIGINT}
</foreach>
</update>
mybatis 批量修改
最新推荐文章于 2024-07-24 17:29:42 发布