【修改】 上传文件参数
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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;
|
||||
|
||||
}
|
Reference in New Issue
Block a user