From 0070c4ca0013c53a17bc8d5cf19495f82e3c271d Mon Sep 17 00:00:00 2001
From: heheng <475597332@qq.com>
Date: Tue, 30 Jun 2026 13:48:34 +0800
Subject: [PATCH] 功能修改
---
expert-admin/src/main/java/com/gkhy/web/controller/common/CommonController.java | 27 ++++++++++++++++++++++-----
1 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/expert-admin/src/main/java/com/gkhy/web/controller/common/CommonController.java b/expert-admin/src/main/java/com/gkhy/web/controller/common/CommonController.java
index be5d96a..6a7322c 100644
--- a/expert-admin/src/main/java/com/gkhy/web/controller/common/CommonController.java
+++ b/expert-admin/src/main/java/com/gkhy/web/controller/common/CommonController.java
@@ -5,6 +5,7 @@
import com.gkhy.common.config.ExpertConfig;
import com.gkhy.common.constant.Constants;
import com.gkhy.common.core.domain.AjaxResult;
+import com.gkhy.common.exception.ServiceException;
import com.gkhy.common.utils.StringUtils;
import com.gkhy.common.utils.file.FileUploadUtils;
import com.gkhy.common.utils.file.FileUtils;
@@ -15,14 +16,12 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.File;
import java.util.ArrayList;
import java.util.List;
@@ -82,7 +81,7 @@
@PostMapping("/upload")
@ApiOperation(value = "通用上传请求(单个)")
@Anonymous
- @RepeatSubmit
+ @RepeatSubmit(interval = 2500, message = "有文件上传中,请上传完成再试")
public AjaxResult uploadFile(MultipartFile file) throws Exception
{
try
@@ -172,4 +171,22 @@
log.error("下载文件失败", e);
}
}
+
+
+ @ApiOperation(value = "删除附件")
+ @DeleteMapping("/removeFile")
+ public void removeFile(@RequestParam(required = true) String path){
+ // 本地资源路径
+ String localPath = ExpertConfig.getProfile();
+ // 数据库资源地址
+ String deletePath = localPath + path;
+ File dirFile=new File(deletePath);
+ if(!dirFile.exists()){
+ throw new ServiceException("文件不存在");
+ }
+ if(!dirFile.isFile()){
+ throw new ServiceException("非文件,不能删除");
+ }
+ dirFile.delete();
+ }
}
--
Gitblit v1.9.2