在Mapper.xml最下面填写

 <!-- 批量插入生成的兑换码 -->
       <insert id ="insertCodeBatch" parameterType="java.util.List" >
              <selectKey resultType ="java.lang.Integer" keyProperty= "id"
                   order= "AFTER">
                  SELECT LAST_INSERT_ID()
              </selectKey >
             insert into redeem_code
             (bach_id, code, type, facevalue,create_user,create_time)
             values
             <foreach collection ="list" item="reddemCode" index= "index" separator =",">
                 (
                 #{reddemCode.batchId}, #{reddemCode.code},
                 #{reddemCode.type},
                 #{reddemCode.facevalue},
                 #{reddemCode.createUser}, #{reddemCode.createTime}
                 )
             </foreach >
      </insert >

 

posted on 2017-12-22 16:28  巨象  阅读(7306)  评论(0编辑  收藏  举报