فهرست منبع

登记簿代码提交,删除记录时删除文件

jingyuanchao 1 سال پیش
والد
کامیت
f3cada10e1

+ 2 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/registerbook/service/ICoreRegisterBookPdfService.java

@@ -35,4 +35,6 @@ public interface ICoreRegisterBookPdfService extends IService<CoreRegisterBookPd
     List<PdfLocalFileTempVo> getDownLoadList(CoreRegisterBookPdfExportDto exportDto);
 
     void downLoad(JSONObject tempVo, HttpServletResponse response);
+
+    Integer deleteWithFile(Long id);
 }

+ 16 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/registerbook/service/impl/CoreRegisterBookPdfServiceImpl.java

@@ -284,4 +284,20 @@ public class CoreRegisterBookPdfServiceImpl extends ServiceImpl<CoreRegisterBook
             }
         }
     }
+
+    @Override
+    public Integer deleteWithFile(Long id) {
+        final CoreRegisterBookPdf record = getById(id);
+        final String fileUrl = record.getFileUrl();
+        if (ObjectUtil.isNotEmpty(fileUrl)){
+            String localPathPrefix = fileService.getLocalPathPrefix().getData();
+            String staticPathPrefix = fileService.getStaticPathPrefix().getData();
+            final String filePath = fileUrl.replace(staticPathPrefix, localPathPrefix);
+            final File file = new File(filePath);
+            if (file.exists()){
+                file.delete();
+            }
+        }
+        return coreRegisterBookPdfMapper.deleteById(id);
+    }
 }