Преглед изворни кода

qhse附件上传功能模块

Zimo пре 13 часа
родитељ
комит
098983ffb5

+ 12 - 0
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java

@@ -25,6 +25,8 @@ import javax.annotation.security.PermitAll;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.Map;
 
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@@ -57,6 +59,16 @@ public class FileController {
         return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));
     }
 
+    @PostMapping("/upload/qhse/path")
+    @Operation(summary = "上传文件", description = "模式一:后端上传文件")
+    public CommonResult<String> uploadQhseFilePath(FileUploadReqVO uploadReqVO) throws Exception {
+        MultipartFile file = uploadReqVO.getFile();
+        String path = uploadReqVO.getPath();
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
+        String format = ZonedDateTime.now().format(formatter);
+        return success(fileService.createFile(format + file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));
+    }
+
     @GetMapping("/presigned-url")
     @Operation(summary = "获取文件预签名地址", description = "模式二:前端上传文件:用于前端直接上传七牛、阿里云 OSS 等文件存储器")
     public CommonResult<FilePresignedUrlRespVO> getFilePresignedUrl(@RequestParam("path") String path) throws Exception {