Kaynağa Gözat

feat:产品要素增加删除功能

chenjianhua 1 hafta önce
ebeveyn
işleme
14fe7b5d48

+ 2 - 0
service-base/src/main/java/com/simuwang/base/mapper/daq/ProductContractMapper.java

@@ -12,4 +12,6 @@ public interface ProductContractMapper extends BaseMapper<ProductContractDO> {
     ProductContractDO selectByNameAndRegisterNumber(@Param("registerNumber") String registerNumber, @Param("productName")String productName);
 
     ProductContractDO selectByProductId(@Param("productId") Integer id);
+
+    void deleteByProductId(@Param("productId") Integer id, @Param("userId") Integer userId);
 }

+ 2 - 0
service-base/src/main/java/com/simuwang/base/mapper/daq/ProductDerivativeMapper.java

@@ -12,4 +12,6 @@ public interface ProductDerivativeMapper extends BaseMapper<ProductDerivativeDO>
     ProductDerivativeDO selectByNameAndRegisterNumber(@Param("registerNumber") String registerNumber, @Param("productName")String productName);
 
     ProductDerivativeDO selectByProductId(@Param("productId") Integer id);
+
+    void deleteByProductId(@Param("productId") Integer id,@Param("userId") Integer userId);
 }

+ 2 - 0
service-base/src/main/java/com/simuwang/base/mapper/daq/ProductInformationMapper.java

@@ -21,4 +21,6 @@ public interface ProductInformationMapper extends BaseMapper<ProductInformationD
     ProductInformationDO selectByRegisterNumber(@Param("registerNumber")String registerNumber);
 
     ProductInformationDO selectByProductName(@Param("productName")String productName);
+
+    void deleteByProductId(@Param("id") Integer id, @Param("userId") Integer userId);
 }

+ 3 - 0
service-base/src/main/resources/mapper/daq/ProductContractMapper.xml

@@ -29,6 +29,9 @@
     INVESTMENT_SCOPE, INVESTMENT_LIMIT, INVESTMENT_STRATEGY, INVESTMENT_METHOD, REMARK,
     ACCRUED_METHOD, ISVALID, CREATETIME, UPDATETIME, CREATORID, UPDATERID
   </sql>
+    <update id="deleteByProductId">
+        update product_contract set isvalid=0,updatetime=now(),updaterid=#{userId} where product_id=#{productId}
+    </update>
     <select id="selectByNameAndRegisterNumber" resultMap="BaseResultMap">
         select ID, PRODUCT_ID, REGISTER_NUMBER, PRODUCT_NAME, PRODUCT_CONTRACT, PERFORMANCE_BASIC,
                INVESTMENT_SCOPE, INVESTMENT_LIMIT, INVESTMENT_STRATEGY, INVESTMENT_METHOD, REMARK,

+ 3 - 0
service-base/src/main/resources/mapper/daq/ProductDerivativeMapper.xml

@@ -39,6 +39,9 @@
     PRODUCT_COUNT, MANAGE_ASSET, FEE_NOTE, MANAGEMENTFEE_TRUST, MANAGEMENTFEE_BANK, OUTSOURCE_FEE, 
     ISVALID, CREATETIME, UPDATETIME, CREATORID, UPDATERID
   </sql>
+    <delete id="deleteByProductId">
+      update product_derivative set isvalid=0,updatetime=now(),updaterid=#{userId} where product_id=#{productId}
+    </delete>
     <select id="selectByNameAndRegisterNumber" resultMap="BaseResultMap">
       select <include refid="Base_Column_List"></include>
       from product_derivative where isvalid=1

+ 3 - 0
service-base/src/main/resources/mapper/daq/ProductInformationMapper.xml

@@ -34,6 +34,9 @@
     NAV_FREQUENCY, ASSET_FREQUENCY, REPORT_FREQUENCY, ISVALID, CREATETIME, UPDATETIME, 
     CREATORID, UPDATERID,INVESTMENT_STRATEGY_DESC
   </sql>
+  <update id="deleteByProductId">
+    update product_information set isvalid=0,updatetime=now(),updaterid=#{userId} where id=#{id}
+  </update>
   <select id="searchProductList" resultMap="BaseResultMap">
     select <include refid="Base_Column_List"></include>
     from product_information where isvalid=1

+ 6 - 0
service-manage/src/main/java/com/simuwang/manage/api/product/ProductController.java

@@ -61,6 +61,12 @@ public class ProductController {
         return productService.uploadProduct(file);
     }
 
+    @SystemLog(value = "删除产品要素", type = SystemLog.Type.UPLOAD_OR_IMPORT)
+    @PostMapping("remove")
+    public ResultVo removeProduct(@RequestBody IdListVO idListVO) {
+        return productService.removeProduct(idListVO.getIdList());
+    }
+
     @SystemLog(value = "查询产品要素明细", type = SystemLog.Type.UPLOAD_OR_IMPORT)
     @GetMapping("/detail")
     public ResultVo productDetail( IdVO idVO) {

+ 2 - 0
service-manage/src/main/java/com/simuwang/manage/service/ProductService.java

@@ -18,4 +18,6 @@ public interface ProductService {
     ResultVo productDetail(IdVO idVO);
 
     List<ProductDataVO> selectProuctInformationByIdList(List<Integer> idList);
+
+    ResultVo removeProduct(List<Integer> idList);
 }

+ 18 - 0
service-manage/src/main/java/com/simuwang/manage/service/impl/ProductServiceImpl.java

@@ -28,6 +28,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
@@ -156,6 +157,23 @@ public class ProductServiceImpl implements ProductService {
         return result;
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public ResultVo removeProduct(List<Integer> idList) {
+        ResultVo vo = new ResultVo(ResultCode.DELETE_SUCCESS);
+        vo.setData(true);
+        vo.setMsg(ResultCode.DELETE_SUCCESS.getMsg());
+        Integer userId = UserUtils.getLoginUser().getUserId();
+        List<ProductInformationDO>  productInformationDOList = productInformationMapper.selectByIdList(idList);
+        for (ProductInformationDO productInformationDO : productInformationDOList) {
+            productInformationMapper.deleteByProductId(productInformationDO.getId(),userId);
+            productContractMapper.deleteByProductId(productInformationDO.getId(),userId);
+            productDerivativeMapper.deleteByProductId(productInformationDO.getId(),userId);
+            investmentManagerMapper.deleteByRegisterNumber(List.of(productInformationDO.getRegisterNumber()));
+        }
+        return vo;
+    }
+
     private ProductUploadResult parseResult(ProductData productData) {
         ProductUploadResult result = new ProductUploadResult();
         int productStartRow = 8;