文件模块已完成

This commit is contained in:
2025-05-06 20:17:59 +08:00
parent e1458e937b
commit ef88f4be1e
18 changed files with 120 additions and 44 deletions

View File

@ -42,7 +42,7 @@ import java.util.List;
* 文件 控制器
*/
@RestController
@RequestMapping("fileInfo")
@RequestMapping("file")
@Slf4j
@Tag(name = "文件管理")
public class FileInfoController {
@ -63,9 +63,9 @@ public class FileInfoController {
@PostMapping("upload")
@Operation(summary = "Web端文件上传服务器", description = "参数文件添加请求体权限管理员方法名addFileInfo")
@SysLog(title = "文件管理", content = "Web端文件上传(服务器)")
public BaseResponse<String> uploadFile(@RequestPart("file") MultipartFile multipartFile, UploadFileRequest uploadFileRequest) {
public BaseResponse<String> uploadFile(@RequestPart("file") MultipartFile multipartFile, UploadFileRequest uploadFileRequest) throws IOException{
// 校验文件
fileInfoService.validFile(multipartFile);
fileInfoService.validFile(multipartFile, uploadFileRequest);
// 文件上传
String view = fileInfoService.uploadFile(multipartFile, uploadFileRequest);
return ResultUtils.success(view, "上传成功");
@ -77,13 +77,13 @@ public class FileInfoController {
/**
* 文件下载(服务器)
* @param filename 文件名
* @param fileName 文件名
* @throws IOException
*/
@GetMapping("/download")
@GetMapping("/download/{fileName}")
@Operation(summary = "文件下载(服务器)", description = "参数文件名权限所有人方法名downloadFile")
public void downloadFile(@RequestParam @NotBlank String filename, HttpServletResponse response) throws IOException {
fileInfoService.downloadFile(filename, response);
public void downloadFile(@PathVariable @NotBlank String fileName, HttpServletResponse response) throws IOException {
fileInfoService.downloadFile(fileName, response);
}
}