fix(controller): 修复文件上传参数绑定与异常处理

- FileController:把 @RequestParam 改成 @RequestPart 并去掉多余注解
- GlobalExceptionHandler:新增 MissingServletRequestPartException 拦截,返回 FILE_IS_EMPTY 错误码
- RequestBodyCacheFilter:跳过 multipart 请求,避免文件上传被缓存过滤器破坏
- UserServiceImpl:修正更新语句为 updateById,防止字段丢失
This commit is contained in:
2026-01-05 20:26:37 +08:00
parent a73a92c0c2
commit 090cb65c0b
4 changed files with 33 additions and 6 deletions

View File

@@ -27,8 +27,7 @@ public class FileController {
@PostMapping("/upload")
@Operation(summary = "上传文件", description = "上传文件接口")
@Parameter(name = "file",required = true,description = "上传的文件")
public BaseResponse<String> upload(@RequestParam("file") MultipartFile file){
public BaseResponse<String> upload(@RequestPart("file") MultipartFile file){
String fileUrl = fileService.upload(file);
return ResultUtils.success(fileUrl);
}