Browse Source

删除、修改标准判定内容是否修改,新增多图片库删除

anderx 1 year ago
parent
commit
0b23063b8d

+ 16 - 4
src/main/java/com/goafanti/standard/service/impl/StandardServiceImpl.java

@@ -32,19 +32,31 @@ public class StandardServiceImpl extends BaseMybatisDao<StandardDocumentMapper>
         Long id = Long.valueOf(in.getId());
         StandardDocument use = standardDocumentMapper.selectByPrimaryKey(id);
         if (StringUtils.isNotEmpty(in.getUrl())){
-            String filePath = uploadPath + "/" + use.getUrl();
-            com.goafanti.common.utils.excel.FileUtils.deleteFile(filePath);
+            deleteFile(use.getUrl());
         }
         return standardDocumentMapper.deleteByPrimaryKey(id);
     }
 
+    private void deleteFile( String url) {
+        if (url.contains(",")){
+            String[] split = url.split(",");
+            for (String s : split) {
+                String filePath = uploadPath + "/" + s;
+                com.goafanti.common.utils.excel.FileUtils.deleteFile(filePath);
+            }
+        }else {
+            String filePath = uploadPath + "/" + url;
+            com.goafanti.common.utils.excel.FileUtils.deleteFile(filePath);
+        }
+
+    }
+
     @Override
     public Object update(StandardDocument in) {
         Long id = Long.valueOf(in.getId());
         StandardDocument use = standardDocumentMapper.selectByPrimaryKey(id);
         if (in.getUrl().equals(use.getUrl())&& StringUtils.isNotEmpty(in.getUrl())){
-            String filePath = uploadPath + "/" + use.getUrl();
-            com.goafanti.common.utils.excel.FileUtils.deleteFile(filePath);
+            deleteFile(use.getUrl());
         }
         return standardDocumentMapper.updateByPrimaryKeySelective(in);
     }