MyBatis批量修改(前后端)

本文介绍了如何使用MyBatis进行批量修改操作,并探讨了@Controller与@RestController的区别,强调在Controller中需要使用@ResponseBody注解以返回JSON数据。同时,分享了前端JavaScript改进前后端交互的方式,确保数据以JSON格式正确传递。
摘要由CSDN通过智能技术生成

虽然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}
               
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值