• SSM批量插入和修改实现实例


    1.Service,自己对代码逻辑进行相应处理

     1 /* 新增订单产品信息 */
     2         List<DmsOrderProduct> insertOrderProductList = Lists.newArrayList();
     3         for (DmsOrderProductVo op : orderVo.getProductList()) {
     4             insertOrderProductList.add(op);
     5         }
     6 
     7         /* 批量新增订单商品信息 */
     8         if (!insertOrderProductList.isEmpty()) {
     9             dmsOrderProductService.batchInsert(insertOrderProductList);
    10         }
    没写接口,自己处理下
    1
    @Override 2 public void batchInsert(List<DmsOrderProduct> orderProductList) { 3 dmsOrderProductMapper.batchInsert(orderProductList); 4 }

    2.持久层

    1  /**
    2      * 批量新增订单产品信息
    3      * @param orderProductList
    4      */
    5     void batchInsert(List<DmsOrderProduct> orderProductList);
     1 <!-- 批量新增订单产品信息 -->
     2   <insert id="batchInsert" parameterType="java.util.List">
     3     insert into dms_order_product
     4     (
     5       order_id, product_id, product_code, product_name, product_spec_id, spec_union_key, shoppingcart_id, unit, original_price,
     6       price, count, return_count, status, promotion_product_id, promotion_subject, created_date, created_by,
     7       last_updated_date, last_updated_by, remove_flag, weight, volume, short_name, spec_name
     8     )
     9     values
    10     <foreach collection="list" index="index" item="item" separator=",">
    11       (
    12         #{item.orderId}, #{item.productId}, #{item.productCode}, #{item.productName}, #{item.productSpecId},
    13         #{item.specUnionKey},#{item.shoppingcartId}, #{item.unit}, #{item.originalPrice}, #{item.price}, #{item.count},
    14         #{item.returnCount}, #{item.status}, #{item.promotionProductId}, #{item.promotionSubject}, #{item.createdDate},
    15         #{item.createdBy}, #{item.lastUpdatedDate}, #{item.lastUpdatedBy}, #{item.removeFlag}, #{item.weight}, #{item.volume},
    16         #{item.shortName}, #{item.specName}
    17       )
    18     </foreach>
    19   </insert>

    细节方面需自己完善下

  • 相关阅读:
    hdu 1251 字典树模板题 ---多串 查找单词出现次数
    一个极其简洁的Python网页抓取程序,自己主动从雅虎財经抓取股票数据
    JSONObject与JSONArray的使用
    关于DPM(Deformable Part Model)算法中模型结构的解释
    fullcalendar日历控件知识点集合
    android--自己定义ProgressDialog显示位置(其他Dialog子类都能够设置)
    最简单的Java框架
    java final keyword
    IBinder对象在进程间传递的形式(一)
    windows的定时任务设置
  • 原文地址:https://www.cnblogs.com/180308-new-file/p/8994027.html
Copyright © 2020-2023  润新知