FileResourceClient.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package com.yihu.ehr.fileresource.service;
  2. import com.yihu.ehr.constants.ApiVersion;
  3. import com.yihu.ehr.constants.MicroServices;
  4. import io.swagger.annotations.ApiOperation;
  5. import org.springframework.cloud.netflix.feign.FeignClient;
  6. import org.springframework.web.bind.annotation.RequestBody;
  7. import org.springframework.web.bind.annotation.RequestMapping;
  8. import org.springframework.web.bind.annotation.RequestMethod;
  9. import org.springframework.web.bind.annotation.RequestParam;
  10. import java.util.List;
  11. /**
  12. * @author linaz
  13. * @created 2016.05.11 11:32
  14. */
  15. @FeignClient(name = MicroServices.FileResource)
  16. public interface FileResourceClient {
  17. @RequestMapping(value = ApiVersion.Version1_0 + "/files_upload", method = RequestMethod.POST)
  18. @ApiOperation(value = "上传文件")
  19. String fileUpload(
  20. @RequestBody String fileStr,
  21. @RequestParam(value = "file_name") String fileName,
  22. @RequestParam(value = "json_data") String jsonData);
  23. @RequestMapping(value = ApiVersion.Version1_0 + "/files_upload_returnUrl", method = RequestMethod.POST)
  24. @ApiOperation(value = "上传文件,并返回存储相对路径")
  25. String fileUploadReturnUrl(
  26. @RequestBody String fileStr,
  27. @RequestParam(value = "file_name") String fileName,
  28. @RequestParam(value = "json_data") String jsonData);
  29. @RequestMapping(value = ApiVersion.Version1_0 + "/files_upload_returnHttpUrl", method = RequestMethod.POST)
  30. @ApiOperation(value = "上传文件,并返回存储绝对路径")
  31. String fileUploadReturnHttpUrl(
  32. @RequestBody String fileStr,
  33. @RequestParam(value = "file_name") String fileName,
  34. @RequestParam(value = "json_data") String jsonData);
  35. @RequestMapping(value = ApiVersion.Version1_0 + "/files", method = RequestMethod.DELETE)
  36. @ApiOperation(value = "删除资源表对应关系,并且删除fastdfs相对应当文件")
  37. boolean filesDelete(
  38. @RequestParam(value = "object_id") String objectId);
  39. @RequestMapping(value = ApiVersion.Version1_0 + "/files_download", method = RequestMethod.GET)
  40. @ApiOperation(value = "下载文件")
  41. List<String> filesDownload(
  42. @RequestParam(value = "object_id") String objectId,
  43. @RequestParam(value = "mime", required = false) String mime);
  44. @RequestMapping(value = ApiVersion.Version1_0 + "/image_view", method = RequestMethod.GET)
  45. @ApiOperation(value = "查看图片")
  46. String imageView(
  47. @RequestParam(value = "storagePath") String storagePath);
  48. @RequestMapping(value = ApiVersion.Version1_0 + "/files_path", method = RequestMethod.GET)
  49. @ApiOperation(value = "获取文件路径")
  50. List<String> filesPath(
  51. @RequestParam(value = "object_id") String objectId);
  52. @RequestMapping(value = ApiVersion.Version1_0 + "/image_delete", method = RequestMethod.DELETE)
  53. @ApiOperation(value = "删除资源表对应关系,并且删除fastdfs相对应当文件")
  54. boolean filesDeleteByPath(
  55. @RequestParam(value = "storagePath") String storagePath);
  56. @ApiOperation(value = "根据文件的id,获取文件的真实访问路径")
  57. @RequestMapping(value = ApiVersion.Version1_0 + "/file/getRealPathById", method = RequestMethod.GET)
  58. String getRealPathById(
  59. @RequestParam(value = "fileId") String fileId);
  60. @ApiOperation(value = "根据文件的存储路径,获取文件的真实访问路径")
  61. @RequestMapping(value = ApiVersion.Version1_0 + "/file/getRealPathByStoragePath", method = RequestMethod.GET)
  62. String getRealPathByStoragePath(
  63. @RequestParam(value = "storagePath") String storagePath);
  64. }