foreach属性-动态-mybatis中使用map类型参数,其中key为列名,value为列值

时间:2022-10-26 10:55:45

 

http://www.cnblogs.com/anruy/p/5942044.html

Integer updateA(@Param("A") Map<String, Double> A);

<update id="updateA" parameterType="java.util.Map">
<foreach collection="A.keys" item="key" index="index" open="" close="" separator=";">
UPDATE TA 
SET status =
<![CDATA[ case when begin_time<DATE_ADD(curdate(),interval -day(curdate())+1 day) then ]]>
CASE WHEN debt - (#{A[${key}]})=0 then 1 else 3 end
else 3 end
WHERE
no = #{key}
</foreach>
</update>