src/main/java/com/se/simu/controller/FilesUploadController.java
@@ -41,6 +41,53 @@
    @ApiOperation("1-上传单个文件")
    @PostMapping("/upload")
    public ResponseEntity<String> upload(@RequestParam("file") MultipartFile file) throws IOException {
        if (file.isEmpty()) {
            return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("文件不能为空");
        }
        String targetDir = Paths.get(uploadedFolder, "upload").toString();
        log.info("目标目录: {}", targetDir);
        createDirectoriesIfNotExists(targetDir);
        try {
            file.transferTo(Paths.get(targetDir, file.getOriginalFilename()));
            return ResponseEntity.ok("文件上传成功");
        } catch (IOException e) {
            log.error("文件上传失败", e);
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("文件上传失败");
        }
    }
    @ApiOperation("2-0上传多个文件")
    @PostMapping("/uploadFiles")
    public ResponseEntity<String> uploadFiles(List<MultipartFile> files) throws IOException {
        if (files.isEmpty()) {
            return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("文件不能为空");
        }
        // 上传文件路径
        String targetDir = Paths.get(uploadedFolder, "upload").toString();
        log.info("目标目录: {}", targetDir);
        createDirectoriesIfNotExists(targetDir);
        CompletableFuture<Void> allUploadTasks = CompletableFuture.allOf(files.stream()
                .map(file -> CompletableFuture.runAsync(() -> {
                    try {
                        file.transferTo(Paths.get(targetDir, file.getOriginalFilename()));
                    } catch (IOException e) {
                        log.error("文件上传失败", e);
                        throw new RuntimeException("文件上传失败");
                    }
                })).toArray(CompletableFuture[]::new));
        try {
            allUploadTasks.get();
            return ResponseEntity.ok("所有文件上传成功!上传目录为:" + targetDir);
        } catch (InterruptedException | ExecutionException e) {
            log.error("文件上传失败", e);
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("文件上传失败");
        }
    }
    @ApiOperation("1-1 -上传单个文件")
    @ApiImplicitParam(name = "filePathName", value = "文件夹名称", required = true, dataType = "String", paramType = "query", example = "upload", dataTypeClass = String.class)
    @PostMapping("/uploadSingleFile")
    public ResponseEntity<String> uploadSingleFile(@RequestParam("file") MultipartFile file, @RequestParam("filePathName") String filePathName) throws IOException {
@@ -68,6 +115,9 @@
    @ApiImplicitParam(name = "filePathName", value = "文件夹名称", required = true, dataType = "String", paramType = "query", example = "upload", dataTypeClass = String.class)
    @PostMapping("/uploadMultipleFiles")
    public ResponseEntity<String> uploadMultipleFiles(List<MultipartFile> files, @RequestParam("filePathName") String filePathName) throws IOException {
        if (files.isEmpty()) {
            return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("文件不能为空");
        }
        // 判断 filePathName 是否为空
        if (filePathName == null || filePathName.isEmpty()) {
            //  return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("文件夹名称不能为空");