2021-06-23 17:01:30 +08:00
|
|
|
package com.ruoyi.demo.controller;
|
|
|
|
|
2022-01-29 11:48:41 +08:00
|
|
|
import com.ruoyi.common.core.domain.R;
|
2022-07-07 18:08:14 +08:00
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
import io.swagger.v3.oas.annotations.Parameters;
|
|
|
|
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
2021-06-23 17:01:30 +08:00
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestPart;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* swagger3 用法示例
|
|
|
|
*
|
|
|
|
* @author Lion Li
|
|
|
|
*/
|
2022-07-07 18:08:14 +08:00
|
|
|
@Tag(name ="演示swagger3控制器", description = "演示swagger3接口")
|
2021-06-23 17:01:30 +08:00
|
|
|
@RestController
|
|
|
|
@RequestMapping("/swagger/demo")
|
|
|
|
public class Swagger3DemoController {
|
|
|
|
|
2021-11-18 17:01:23 +08:00
|
|
|
/**
|
|
|
|
* 上传请求
|
|
|
|
* 必须使用 @RequestPart 注解标注为文件
|
|
|
|
*/
|
2022-07-07 18:08:14 +08:00
|
|
|
@Parameters({
|
|
|
|
@Parameter(name = "file", description = "文件", in = ParameterIn.QUERY, required = true)
|
2021-11-18 17:01:23 +08:00
|
|
|
})
|
|
|
|
@PostMapping(value = "/upload")
|
2022-01-29 11:48:41 +08:00
|
|
|
public R<String> upload(@RequestPart("file") MultipartFile file) {
|
|
|
|
return R.ok("操作成功", file.getOriginalFilename());
|
2021-11-18 17:01:23 +08:00
|
|
|
}
|
2021-06-23 17:01:30 +08:00
|
|
|
|
|
|
|
}
|