UploadController.java 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. package com.diagbot.web;
  2. import com.diagbot.dto.FileDTO;
  3. import com.diagbot.dto.RespDTO;
  4. import com.diagbot.facade.UploadFacade;
  5. import io.swagger.annotations.Api;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.web.bind.annotation.GetMapping;
  8. import org.springframework.web.bind.annotation.PostMapping;
  9. import org.springframework.web.bind.annotation.RequestMapping;
  10. import org.springframework.web.bind.annotation.RequestParam;
  11. import org.springframework.web.bind.annotation.RestController;
  12. import org.springframework.web.multipart.MultipartFile;
  13. @RestController
  14. @Api(value = "文件上传API", tags = { "文件上传API" })
  15. @RequestMapping(value = "/file")
  16. @SuppressWarnings("unchecked")
  17. public class UploadController {
  18. @Autowired
  19. private UploadFacade uploadFacade;
  20. @GetMapping("/uploadImage")
  21. public RespDTO<FileDTO> singleFileUpload(@RequestParam("upfile") MultipartFile file) {
  22. return RespDTO.onSuc(uploadFacade.singleFileUpload(file));
  23. }
  24. @PostMapping("/deleteRemoteFile")
  25. public RespDTO<Boolean> deleteRemoteFile(@RequestParam("path") String path) {
  26. return RespDTO.onSuc(uploadFacade.deleteRemoteFile(path));
  27. }
  28. }