【修改】 上传文件参数

This commit is contained in:
dlaren
2025-08-11 00:13:51 +08:00
parent 96d609e13c
commit 851cc9e1cb
2 changed files with 19 additions and 3 deletions

View File

@@ -290,12 +290,12 @@ public class ExamQuestionController {
* 试题预览
*/
@PostMapping("/previewQuestion")
public CommonResult<String> previewQuestion(@RequestPart("file") MultipartFile file) throws IOException {
public CommonResult<String> previewQuestion(FileUploadReqVO file) throws IOException {
// 先判断是否为.c的文件
if (!file.getOriginalFilename().endsWith(".c")) {
if (!file.getFile().getOriginalFilename().endsWith(".c")) {
return CommonResult.error(100810, "请上传.c文件");
}
return CommonResult.success(new String(file.getBytes(), StandardCharsets.UTF_8));
return CommonResult.success(new String(file.getFile().getBytes(), StandardCharsets.UTF_8));
}
}

View File

@@ -0,0 +1,16 @@
package pc.exam.pp.module.exam.controller.admin.question.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
@Schema(description = "管理后台 - 上传文件 Request VO")
@Data
public class FileUploadReqVO {
@Schema(description = "文件附件", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "文件附件不能为空")
private MultipartFile file;
}