Bläddra i källkod

物料批量删除增加错误信息返回

chenw 7 år sedan
förälder
incheckning
d82291b9d0

+ 4 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/ProductController.java

@@ -80,7 +80,10 @@ public class ProductController {
 
     @PostMapping("/batchDelete")
     public Result batchDelete(@RequestBody BatchDealBaseDTO baseDTOs){
-        productService.batchDelete(baseDTOs);
+        String result = productService.batchDelete(baseDTOs);
+        if (!StringUtils.isEmpty(result)){
+            return Result.error(result);
+        }
         return Result.success();
     }
 

+ 1 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/ProductService.java

@@ -95,7 +95,7 @@ public interface ProductService extends CommonBaseService<ProductMapper, Product
      * @param baseDTOs
      * @return
      */
-    boolean batchDelete(BatchDealBaseDTO baseDTOs);
+    String batchDelete(BatchDealBaseDTO baseDTOs);
 
     /**
      * 通过ID获取物料信息

+ 9 - 3
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/ProductServiceImpl.java

@@ -535,11 +535,17 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
 
     @Override
     @Transactional
-    public boolean batchDelete(BatchDealBaseDTO baseDTOs) {
+    public String batchDelete(BatchDealBaseDTO baseDTOs) {
+        StringBuilder errorMsg = new StringBuilder();
         for(DocBaseDTO docBaseDTO : baseDTOs.getBaseDTOs()){
-            deleteByPrimaryKey(docBaseDTO.getId());
+            try {
+                deleteByPrimaryKey(docBaseDTO.getId());
+            }catch (Exception e){
+                String msg = BizExceptionCode.DEAL_FAILED.getMessage();
+                errorMsg.append(String.format(msg, docBaseDTO.getCode(), e.getMessage()) + "<br />");
+            }
         }
-        return true;
+        return errorMsg.toString();
     }
 
     @Override