Mybatis 批量新增和修改

<update id="batchUpdateReserList" parameterType="java.util.List">
    <foreach collection="reservationList" item="item" index="index" open="" close="" separator=";">
      update t_sds_room_reservation
      <set>
        <if test="item.status != null and item.status !='' " >
          status = #{item.status,jdbcType=VARCHAR},
        </if>
        <if test="item.remark != null and item.remark != ''" >
          remark = #{item.remark,jdbcType=VARCHAR},
        </if>
        <if test="@com.paascloud.PublicUtil@isNotEmpty(item.approvedPhone)">
          approved_phone = #{item.approvedPhone,jdbcType=VARCHAR},
        </if>
        <if test="@com.paascloud.PublicUtil@isNotEmpty(item.contactNum)">
          contact_num = #{item.contactNum,jdbcType=VARCHAR},
        </if>
      </set>
      where id = #{item.id,jdbcType=BIGINT}
    </foreach>

  </update>

新增

<insert id="batchInsertReserList" parameterType="java.util.List">
    insert into t_sds_room_reservation(`id`,`room_id`,`estimated_occupancy`,`contact_num`,`approve_status`,`remark`,`status`,`check_in_time`,`check_out_time`,`organization_id`,`company_id`,`create_by`,
    `create_time`,`expense_org`,`approved_by`,`approved_phone`)

    VALUES
    <foreach collection="reservationList" item="reser" index="index" separator=",">

      (
      #{reser.id},#{reser.roomId},#{reser.estimatedOccupancy},#{reser.contactNum},#{reser.approveStatus},#{reser.remark},#{reser.status},#{reser.checkInTime},#{reser.checkOutTime},
      #{reser.organizationId},#{reser.companyId},#{reser.createBy},#{reser.createTime},#{reser.expenseOrg},#{reser.approvedBy},#{reser.approvedPhone}
      )

    </foreach>
  </insert>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值