mybatis 单表 批量操作

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.suning.pbr.mapper.InfoDefaultInputBatchMapper" >
   
  <insert id="batchInsert" parameterType="java.util.List">
	 insert into info_default_input 
	 (id, nc_id, content, seq, update_time, operator, op_name)
      values  (
   	<foreach item="item" collection="list" open="" close="" separator="),(">
	        #{item.id,jdbcType=BIGINT}
	      , #{item.ncId,jdbcType=INTEGER}
	      , #{item.content,jdbcType=VARCHAR}
	      , #{item.seq,jdbcType=DECIMAL}
	      , #{item.updateTime,jdbcType=TIMESTAMP}
	      , #{item.operator,jdbcType=BIGINT}
	      , #{item.opName,jdbcType=VARCHAR}
      </foreach>
       )
  </insert>
  
  <update id="batchUpdate" parameterType="java.util.List" >  
           update info_default_input   
           <trim prefix="set" suffixOverrides=",">  
	           <trim prefix="content =case" suffix="end ,">  
	                <foreach collection="list" item="item"  index="index">  
	                        <if test="item.content!=null">  
	                         when id=#{item.id} then #{item.content}  
	                        </if>
	                </foreach>  
	            </trim>  
	            <trim prefix="update_time =case" suffix="end ,">  
	                <foreach collection="list" item="item"  index="index">  
	                        <if test="item.updateTime!=null">  
	                         when id=#{item.id} then #{item.updateTime}  
	                        </if>  
	                </foreach>  
	            </trim>  
	            
	            <trim prefix="seq =case" suffix="end ,">  
	                <foreach collection="list" item="item"  index="index">  
	                        <if test="item.seq!=null">  
	                         when id=#{item.id} then #{item.seq}  
	                        </if>  
	                </foreach>  
	            </trim>  
	               
	            <trim prefix="operator =case" suffix="end ,">  
	                <foreach collection="list" item="item"  index="index">  
	                        <if test="item.operator!=null">  
	                         when id=#{item.id} then #{item.operator}  
	                        </if>  
	                </foreach>  
	            </trim>  
	            <trim prefix="op_name =case" suffix="end ,">  
	                <foreach collection="list" item="item"  index="index">  
	                        <if test="item.opName!=null">  
	                         when id=#{item.id} then #{item.opName}  
	                        </if>  
	                </foreach>  
	            </trim>   
	        </trim>
	        where ID in (
		       <foreach  collection="list" item="item" open="" close="" separator=",">
		  			#{item.id,jdbcType=BIGINT}
		       </foreach>
	       )
  </update>  
  
  <delete id="batchDelete" parameterType="java.util.List" >
    	delete from info_default_input
    		where ID in(
       	<foreach item="item" collection="list" open="" close="" separator=",">
  			#{item.id,jdbcType=BIGINT}
       </foreach>
      	)
  </delete>
</mapper>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值