1.js:首先序列化表单然后将值传到后台
2.Controller:
获取前台传来的序列化表单,并转化为List集合:
3.Service以及ServiceImpl层:
4.Mybatis:
字段以及数据库类型一定要对应
批量插入:
1 <insert id="insertBatch" parameterType="java.util.Map"> 2 insert into customs_declare_bill_detail( 3 id, 4 gno, 5 relman_no, 6 code_t, 7 g_name, 8 g_model, 9 g_qty, 10 g_unit, 11 decl_total, 12 decl_curr, 13 decl_price, 14 exg_version, 15 goods_no, 16 origin_country, 17 unit_1, 18 qty_1, 19 unit_2, 20 qty_2, 21 duty_mode, 22 work_usd, 23 dest_country, 24 rtn_code, 25 rtn_info, 26 invalid, 27 bill_id, 28 main_factor, 29 bill_no, 30 creator, 31 create_time, 32 amender, 33 amend_time) 34 values 35 <foreach collection="list" item="item" index="index" separator=","> 36 ( 37 #{item.id,jdbcType=BIGINT}, 38 #{item.gno,jdbcType=VARCHAR}, 39 #{item.relmanNo,jdbcType=VARCHAR}, 40 #{item.codeT,jdbcType=VARCHAR}, 41 #{item.gName,jdbcType=VARCHAR}, 42 #{item.gModel,jdbcType=VARCHAR}, 43 #{item.gQty,jdbcType=INTEGER}, 44 #{item.gUnit,jdbcType=VARCHAR}, 45 #{item.declTotal,jdbcType=DECIMAL}, 46 #{item.declCurr,jdbcType=VARCHAR}, 47 #{item.declPrice,jdbcType=DECIMAL}, 48 #{item.exgVersion,jdbcType=VARCHAR}, 49 #{item.goodsNo,jdbcType=VARCHAR}, 50 #{item.originCountry,jdbcType=VARCHAR}, 51 #{item.unit1,jdbcType=VARCHAR}, 52 #{item.qty1,jdbcType=DECIMAL}, 53 #{item.unit2,jdbcType=VARCHAR}, 54 #{item.qty2,jdbcType=DECIMAL}, 55 #{item.dutyMode,jdbcType=VARCHAR}, 56 #{item.workUsd,jdbcType=DECIMAL}, 57 #{item.destCountry,jdbcType=VARCHAR}, 58 #{item.rtnCode,jdbcType=VARCHAR}, 59 #{item.rtnInfo,jdbcType=VARCHAR}, 60 #{item.invalid,jdbcType=VARCHAR}, 61 #{item.billId,jdbcType=BIGINT}, 62 #{item.mainFactor,jdbcType=VARCHAR}, 63 #{item.billNo,jdbcType=VARCHAR}, 64 #{item.creator,jdbcType=INTEGER}, 65 #{item.createTime,jdbcType=TIMESTAMP}, 66 #{item.amender,jdbcType=INTEGER}, 67 #{item.amendTime,jdbcType=TIMESTAMP} 68 ) 69 </foreach> 70 </insert>
2.批量删除:
<delete id="deleteById" parameterType="java.lang.String">
delete from customs_declare_bill_detail where id in
<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
#{item}
</foreach>
</delete>