Swagger3DemoController.java 917 B

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