From 152a386ac1d64e42838b893190d773d8874a6406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Wed, 23 Jun 2021 17:01:30 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E5=A2=9E=E5=8A=A0=20Swagger3=20=E7=94=A8?= =?UTF-8?q?=E6=B3=95=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/Swagger3DemoController.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 ruoyi-demo/src/main/java/com/ruoyi/demo/controller/Swagger3DemoController.java diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/Swagger3DemoController.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/Swagger3DemoController.java new file mode 100644 index 00000000..a8efb64e --- /dev/null +++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/Swagger3DemoController.java @@ -0,0 +1,38 @@ +package com.ruoyi.demo.controller; + +import com.ruoyi.common.core.domain.AjaxResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +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 + */ +@Api(value = "演示swagger3控制器", tags = {"演示swagger3接口"}) +@RestController +@RequestMapping("/swagger/demo") +public class Swagger3DemoController { + + /** + * 上传请求 + * 必须使用 @RequestPart 注解标注为文件 + * dataType 必须为 "java.io.File" + */ + @ApiOperation(value = "通用上传请求") + @ApiImplicitParams({ + @ApiImplicitParam(name = "file", value = "文件", dataType = "java.io.File", required = true), + }) + @PostMapping(value = "/upload") + public AjaxResult upload(@RequestPart("file") MultipartFile file) { + return AjaxResult.success("操作成功", file.getOriginalFilename()); + } + +}