yonge 5 years ago
parent
commit
8a50b3597f

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ChargeTypeSubjectMapperDao.java

@@ -1,5 +1,7 @@
 package com.ym.mec.biz.dal.dao;
 package com.ym.mec.biz.dal.dao;
 
 
+import java.util.List;
+
 import com.ym.mec.biz.dal.entity.ChargeTypeSubjectMapper;
 import com.ym.mec.biz.dal.entity.ChargeTypeSubjectMapper;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.dal.BaseDAO;
 
 
@@ -10,4 +12,7 @@ public interface ChargeTypeSubjectMapperDao extends BaseDAO<Long, ChargeTypeSubj
      */
      */
     void deleteByChargeTypeId(Integer chargeTypeId);
     void deleteByChargeTypeId(Integer chargeTypeId);
 
 
+	int batchInsert(List<ChargeTypeSubjectMapper> chargeTypeSubjectMapperList);
+	
+	int batchUpdate(List<ChargeTypeSubjectMapper> chargeTypeSubjectMapperList);
 }
 }

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/ChargeTypeSubjectMapperService.java

@@ -1,9 +1,15 @@
 package com.ym.mec.biz.service;
 package com.ym.mec.biz.service;
 
 
+import java.util.List;
+
 import com.ym.mec.biz.dal.entity.ChargeTypeSubjectMapper;
 import com.ym.mec.biz.dal.entity.ChargeTypeSubjectMapper;
 import com.ym.mec.common.service.BaseService;
 import com.ym.mec.common.service.BaseService;
 
 
 public interface ChargeTypeSubjectMapperService extends BaseService<Long, ChargeTypeSubjectMapper> {
 public interface ChargeTypeSubjectMapperService extends BaseService<Long, ChargeTypeSubjectMapper> {
 
 
 	boolean deleteById(Long id);
 	boolean deleteById(Long id);
+	
+	boolean batchInsert(List<ChargeTypeSubjectMapper> chargeTypeSubjectMapperList);
+	
+	boolean batchUpdate(List<ChargeTypeSubjectMapper> chargeTypeSubjectMapperList);
 }
 }

+ 14 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ChargeTypeSubjectMapperServiceImpl.java

@@ -1,5 +1,7 @@
 package com.ym.mec.biz.service.impl;
 package com.ym.mec.biz.service.impl;
 
 
+import java.util.List;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
@@ -25,5 +27,17 @@ public class ChargeTypeSubjectMapperServiceImpl extends BaseServiceImpl<Long, Ch
 		chargeTypeSubjectMapperDao.delete(id);
 		chargeTypeSubjectMapperDao.delete(id);
 		return true;
 		return true;
 	}
 	}
+
+	@Override
+	public boolean batchInsert(List<ChargeTypeSubjectMapper> chargeTypeSubjectMapperList) {
+		chargeTypeSubjectMapperDao.batchInsert(chargeTypeSubjectMapperList);
+		return true;
+	}
+
+	@Override
+	public boolean batchUpdate(List<ChargeTypeSubjectMapper> chargeTypeSubjectMapperList) {
+		chargeTypeSubjectMapperDao.batchUpdate(chargeTypeSubjectMapperList);
+		return true;
+	}
 	
 	
 }
 }

+ 40 - 0
mec-biz/src/main/resources/config/mybatis/ChargeTypeSubjectMapperMapper.xml

@@ -34,6 +34,16 @@
         INSERT INTO charge_type_subject_mapper (charge_type_id_,subject_id_,kit_group_purchase_type_,deposit_fee_,fee_,goods_discount_rate_,create_time_,update_time_)
         INSERT INTO charge_type_subject_mapper (charge_type_id_,subject_id_,kit_group_purchase_type_,deposit_fee_,fee_,goods_discount_rate_,create_time_,update_time_)
         VALUES(#{chargeTypeId},#{subjectId},#{kitGroupPurchaseTypeEnum,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{depositFee},#{fee},#{goodsDiscountRate},now(),now())
         VALUES(#{chargeTypeId},#{subjectId},#{kitGroupPurchaseTypeEnum,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{depositFee},#{fee},#{goodsDiscountRate},now(),now())
     </insert>
     </insert>
+
+    <!-- 向数据库增加一条记录 -->
+    <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id"
+            keyProperty="id">
+        INSERT INTO charge_type_subject_mapper (charge_type_id_,subject_id_,kit_group_purchase_type_,deposit_fee_,fee_,goods_discount_rate_,create_time_,update_time_)
+        VALUES
+        <foreach collection="list" item="item" separator=",">
+        (#{item.chargeTypeId},#{item.subjectId},#{item.kitGroupPurchaseTypeEnum,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.depositFee},#{item.fee},#{item.goodsDiscountRate},now(),now())
+        </foreach>
+    </insert>
     
     
     <!-- 根据主键查询一条记录 -->
     <!-- 根据主键查询一条记录 -->
     <update id="update" parameterType="com.ym.mec.biz.dal.entity.ChargeTypeSubjectMapper">
     <update id="update" parameterType="com.ym.mec.biz.dal.entity.ChargeTypeSubjectMapper">
@@ -63,6 +73,36 @@
         </set>
         </set>
         WHERE id_ = #{id}
         WHERE id_ = #{id}
     </update>
     </update>
+    
+    <update id="batchUpdate" parameterType="java.util.List">
+        <foreach collection="list" item="item" index="index" open="" close="" separator=";">
+        UPDATE charge_type_subject_mapper
+        <set>
+            <if test="item.subjectId != null">
+                subject_id_ = #{item.subjectId},
+            </if>
+            <if test="item.chargeTypeId != null">
+                charge_type_id_ = #{item.chargeTypeId},
+            </if>
+            <if test="item.kitGroupPurchaseTypeEnum != null">
+                kit_group_purchase_type_ = #{item.kitGroupPurchaseTypeEnum, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+            </if>
+            <if test="item.depositFee != null">
+                deposit_fee_ = #{item.depositFee},
+            </if>
+            <if test="item.fee != null">
+                fee_ = #{item.fee},
+            </if>
+            <if test="item.goodsDiscountRate != null">
+                goods_discount_rate_ = #{item.goodsDiscountRate},
+            </if>
+            <if test="item.updateTime != null">
+                update_time_ = NOW(),
+            </if>
+        </set>
+            WHERE id_ = #{item.id}
+        </foreach>
+    </update>
 
 
     <!-- 根据主键删除一条记录 -->
     <!-- 根据主键删除一条记录 -->
     <delete id="delete">
     <delete id="delete">

+ 7 - 5
mec-web/src/main/java/com/ym/mec/web/controller/ChargeTypeSubjectMapperController.java

@@ -1,5 +1,7 @@
 package com.ym.mec.web.controller;
 package com.ym.mec.web.controller;
 
 
+import java.util.List;
+
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import io.swagger.annotations.ApiParam;
@@ -36,17 +38,17 @@ public class ChargeTypeSubjectMapperController extends BaseController {
 
 
     @ApiOperation(value = "新增对象")
     @ApiOperation(value = "新增对象")
 	@PostMapping(value = "/insert", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
 	@PostMapping(value = "/insert", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
-    @PreAuthorize("@pcs.hasPermissions('chargeTypeSubjectMapper/update')")
-    public Object insert(@RequestBody ChargeTypeSubjectMapper chargeTypeSubjectMapper) {
-    	chargeTypeSubjectMapperService.insert(chargeTypeSubjectMapper);
+    @PreAuthorize("@pcs.hasPermissions('chargeTypeSubjectMapper/insert')")
+    public Object insert(@RequestBody List<ChargeTypeSubjectMapper> chargeTypeSubjectMapperList) {
+    	chargeTypeSubjectMapperService.batchInsert(chargeTypeSubjectMapperList);
         return succeed();
         return succeed();
     }
     }
 
 
     @ApiOperation(value = "修改对象")
     @ApiOperation(value = "修改对象")
 	@PostMapping(value = "/update", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
 	@PostMapping(value = "/update", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
     @PreAuthorize("@pcs.hasPermissions('chargeTypeSubjectMapper/update')")
     @PreAuthorize("@pcs.hasPermissions('chargeTypeSubjectMapper/update')")
-    public Object update(@RequestBody ChargeTypeSubjectMapper chargeTypeSubjectMapper) {
-    	chargeTypeSubjectMapperService.update(chargeTypeSubjectMapper);
+    public Object update(@RequestBody List<ChargeTypeSubjectMapper> chargeTypeSubjectMapperList) {
+    	chargeTypeSubjectMapperService.batchUpdate(chargeTypeSubjectMapperList);
         return succeed();
         return succeed();
     }
     }