Commit e757d172029e33f48caf699350c498fc6682c5aa
1 parent
7093ed39
【修复】swagger上传文件没有 file 参数
Showing
3 changed files
with
25 additions
and
22 deletions
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java
| ... | ... | @@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; |
| 7 | 7 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 8 | 8 | import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePageReqVO; |
| 9 | 9 | import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FileRespVO; |
| 10 | +import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FileUploadReqVO; | |
| 10 | 11 | import cn.iocoder.yudao.module.infra.convert.file.FileConvert; |
| 11 | 12 | import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO; |
| 12 | 13 | import cn.iocoder.yudao.module.infra.service.file.FileService; |
| ... | ... | @@ -40,13 +41,10 @@ public class FileController { |
| 40 | 41 | |
| 41 | 42 | @PostMapping("/upload") |
| 42 | 43 | @ApiOperation("上传文件") |
| 43 | - @ApiImplicitParams({ | |
| 44 | - @ApiImplicitParam(name = "file", value = "文件附件", required = true, dataTypeClass = MultipartFile.class), | |
| 45 | - @ApiImplicitParam(name = "path", value = "文件路径", example = "yudaoyuanma.png", dataTypeClass = String.class) | |
| 46 | - }) | |
| 47 | 44 | @OperateLog(logArgs = false) // 上传文件,没有记录操作日志的必要 |
| 48 | - public CommonResult<String> uploadFile(@RequestParam("file") MultipartFile file, | |
| 49 | - @RequestParam(value = "path", required = false) String path) throws Exception { | |
| 45 | + public CommonResult<String> uploadFile(FileUploadReqVO uploadReqVO) throws Exception { | |
| 46 | + MultipartFile file = uploadReqVO.getFile(); | |
| 47 | + String path = uploadReqVO.getPath(); | |
| 50 | 48 | return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream()))); |
| 51 | 49 | } |
| 52 | 50 | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/vo/file/FileUploadReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.controller.admin.file.vo.file; | |
| 2 | + | |
| 3 | +import io.swagger.annotations.ApiModel; | |
| 4 | +import io.swagger.annotations.ApiModelProperty; | |
| 5 | +import lombok.Data; | |
| 6 | +import org.springframework.web.multipart.MultipartFile; | |
| 7 | + | |
| 8 | +import javax.validation.constraints.NotNull; | |
| 9 | + | |
| 10 | +@ApiModel(value = "管理后台 - 上传文件 Request VO") | |
| 11 | +@Data | |
| 12 | +public class FileUploadReqVO { | |
| 13 | + | |
| 14 | + @ApiModelProperty(value = "文件附件", required = true) | |
| 15 | + @NotNull(message = "文件附件不能为空") | |
| 16 | + private MultipartFile file; | |
| 17 | + | |
| 18 | + @ApiModelProperty(value = "文件附件", example = "yudaoyuanma.png") | |
| 19 | + private String path; | |
| 20 | + | |
| 21 | +} | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/vo/file/UploadRespVO.java deleted
| 1 | -package cn.iocoder.yudao.module.infra.controller.admin.file.vo.file; | |
| 2 | - | |
| 3 | -import io.swagger.annotations.ApiModel; | |
| 4 | -import io.swagger.annotations.ApiModelProperty; | |
| 5 | -import lombok.Data; | |
| 6 | - | |
| 7 | -@Data | |
| 8 | -@ApiModel(value = "管理后台 - 上传文件 VO") | |
| 9 | -public class UploadRespVO { | |
| 10 | - | |
| 11 | - @ApiModelProperty(value = "文件名", required = true, example = "yudao.jpg") | |
| 12 | - private String fileName; | |
| 13 | - | |
| 14 | - @ApiModelProperty(value = "文件 URL", required = true, example = "https://www.iocoder.cn/yudao.jpg") | |
| 15 | - private String fileUrl; | |
| 16 | -} |