mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 01:01:52 +08:00
【修复】swagger上传文件没有 file 参数
This commit is contained in:
parent
7093ed3997
commit
e757d17202
@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
|||||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePageReqVO;
|
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePageReqVO;
|
||||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FileRespVO;
|
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FileRespVO;
|
||||||
|
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FileUploadReqVO;
|
||||||
import cn.iocoder.yudao.module.infra.convert.file.FileConvert;
|
import cn.iocoder.yudao.module.infra.convert.file.FileConvert;
|
||||||
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
|
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
|
||||||
import cn.iocoder.yudao.module.infra.service.file.FileService;
|
import cn.iocoder.yudao.module.infra.service.file.FileService;
|
||||||
@ -40,13 +41,10 @@ public class FileController {
|
|||||||
|
|
||||||
@PostMapping("/upload")
|
@PostMapping("/upload")
|
||||||
@ApiOperation("上传文件")
|
@ApiOperation("上传文件")
|
||||||
@ApiImplicitParams({
|
|
||||||
@ApiImplicitParam(name = "file", value = "文件附件", required = true, dataTypeClass = MultipartFile.class),
|
|
||||||
@ApiImplicitParam(name = "path", value = "文件路径", example = "yudaoyuanma.png", dataTypeClass = String.class)
|
|
||||||
})
|
|
||||||
@OperateLog(logArgs = false) // 上传文件,没有记录操作日志的必要
|
@OperateLog(logArgs = false) // 上传文件,没有记录操作日志的必要
|
||||||
public CommonResult<String> uploadFile(@RequestParam("file") MultipartFile file,
|
public CommonResult<String> uploadFile(FileUploadReqVO uploadReqVO) throws Exception {
|
||||||
@RequestParam(value = "path", required = false) String path) throws Exception {
|
MultipartFile file = uploadReqVO.getFile();
|
||||||
|
String path = uploadReqVO.getPath();
|
||||||
return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));
|
return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package cn.iocoder.yudao.module.infra.controller.admin.file.vo.file;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@ApiModel(value = "管理后台 - 上传文件 Request VO")
|
||||||
|
@Data
|
||||||
|
public class FileUploadReqVO {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "文件附件", required = true)
|
||||||
|
@NotNull(message = "文件附件不能为空")
|
||||||
|
private MultipartFile file;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "文件附件", example = "yudaoyuanma.png")
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
}
|
@ -1,16 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.infra.controller.admin.file.vo.file;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@ApiModel(value = "管理后台 - 上传文件 VO")
|
|
||||||
public class UploadRespVO {
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "文件名", required = true, example = "yudao.jpg")
|
|
||||||
private String fileName;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "文件 URL", required = true, example = "https://www.iocoder.cn/yudao.jpg")
|
|
||||||
private String fileUrl;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user