Swagger3DemoController.java 964 B

1234567891011121314151617181920212223242526272829303132
  1. package com.ruoyi.demo.controller;
  2. import com.ruoyi.common.core.domain.R;
  3. import io.swagger.v3.oas.annotations.tags.Tag;
  4. import org.springframework.http.MediaType;
  5. import org.springframework.web.bind.annotation.PostMapping;
  6. import org.springframework.web.bind.annotation.RequestMapping;
  7. import org.springframework.web.bind.annotation.RequestPart;
  8. import org.springframework.web.bind.annotation.RestController;
  9. import org.springframework.web.multipart.MultipartFile;
  10. /**
  11. * swagger3 用法示例
  12. *
  13. * @author Lion Li
  14. */
  15. @RestController
  16. @RequestMapping("/swagger/demo")
  17. public class Swagger3DemoController {
  18. /**
  19. * 上传请求
  20. * 必须使用 @RequestPart 注解标注为文件
  21. *
  22. * @param file 文件
  23. */
  24. @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
  25. public R<String> upload(@RequestPart("file") MultipartFile file) {
  26. return R.ok("操作成功", file.getOriginalFilename());
  27. }
  28. }