소스 검색

加入删除文件根据url

liyanbo 1 개월 전
부모
커밋
39b0abf505
1개의 변경된 파일13개의 추가작업 그리고 0개의 파일을 삭제
  1. 13 0
      byzs-module-infra/src/main/java/cn/iocoder/byzs/module/infra/controller/admin/file/FileController.java

+ 13 - 0
byzs-module-infra/src/main/java/cn/iocoder/byzs/module/infra/controller/admin/file/FileController.java

@@ -91,6 +91,19 @@ public class FileController {
         return success(true);
     }
 
+    @DeleteMapping("/delete-by-url")
+    @Operation(summary = "根据 URL 删除文件")
+    @Parameter(name = "url", description = "文件 URL", required = true)
+    @PreAuthorize("@ss.hasPermission('infra:file:delete')")
+    public CommonResult<Boolean> deleteFileByUrl(@RequestParam("url") String url) throws Exception {
+        FileDO fileDO = fileService.getFilePathByUrl(url);
+        if (fileDO == null) {
+            throw new IllegalArgumentException("文件不存在");
+        }
+        fileService.deleteFile(fileDO.getId());
+        return success(true);
+    }
+
     @GetMapping("/{configId}/get/**")
     @PermitAll
     @TenantIgnore