From f68b70dc3d5d3b52e89b3e47ef9914d99ea04e67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Wed, 11 Mar 2026 17:47:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20bug-1369=20=E5=B7=A5=E6=9C=8D=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=EF=BC=8C=E6=9C=8D=E5=8A=A1=E6=8A=A5=E5=91=8A=E9=87=8C?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=8A=A5=E5=91=8A=EF=BC=8C=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E6=B4=BE=E5=B7=A5=E7=BB=93=E6=A1=88=E6=97=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E9=99=84=E4=BB=B6=E6=8A=A5=E5=91=8A=E6=97=B6=EF=BC=8C=E9=99=90?= =?UTF-8?q?=E5=88=B6=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E5=9C=A81G?= =?UTF-8?q?=E4=BB=A5=E5=86=85=EF=BC=8C=E5=B9=B6=E5=A2=9E=E5=8A=A0=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E8=BF=9B=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gongfu/controller/FileController.java | 27 +++++-------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/FileController.java b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/FileController.java index 678a87d4..9c11068b 100644 --- a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/FileController.java +++ b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/FileController.java @@ -23,6 +23,7 @@ import javax.validation.Valid; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import java.io.IOException; +import java.net.URL; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.List; @@ -36,14 +37,9 @@ import java.util.Objects; @RequestMapping("/file") public class FileController extends ControllerBase { - private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd"); - @Resource private IGongfuFileService fileService; - @Resource - private FileUploadService fileUploadService; - /** * 文件搜索 */ @@ -59,35 +55,24 @@ public class FileController extends ControllerBase { /** * 文件上传 - * @param type 类型,1:服务月报 + * @param type 类型,1:服务月报 * @param fileName 文件名称 - * @param file 文件 + * @param fileUrl 文件地址 */ @PostMapping("/upload") - public ApiResult upload(@RequestParam Integer type,@RequestParam String fileName,@RequestParam MultipartFile file) throws IOException { - String url = fileUploadService.upload(buildFilePath(getFileType(file.getOriginalFilename())), file); + public ApiResult upload(@RequestParam Integer type, @RequestParam String fileName, @RequestParam String fileUrl) throws IOException { fileService.save( new GongfuFile() .setType(type) .setFileName(fileName) - .setFileSize(file.getSize()) - .setFileSuffix(FilenameUtils.getExtension(file.getOriginalFilename())) - .setFileUrl(url) + .setFileSuffix(FilenameUtils.getExtension(new URL(fileUrl).getPath())) + .setFileUrl(fileUrl) .setCreateBy(AdminUserUtil.getUserName()) .setCreateTime(LocalDateTime.now()) ); return ApiResult.success(); } - private String buildFilePath(String fileType) { - return StrUtil.format("gongfu/{}/{}/{}/{}{}", LocalDateTime.now().format(FORMATTER), AdminUserUtil.getUserId() - , RandomUtil.randomString(4), IdUtil.fastUUID(), fileType); - } - - private String getFileType(String fileName) { - return "." + FilenameUtils.getExtension(fileName).toLowerCase(); - } - /** * 文件删除 */