SceneFileController.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. package com.fdkankan.scene.controller;
  2. import com.fdkankan.common.controller.BaseController;
  3. import com.fdkankan.common.response.ResultData;
  4. import com.fdkankan.redis.util.RedisLockUtil;
  5. import com.fdkankan.scene.service.ISceneFileBuildService;
  6. import com.fdkankan.scene.vo.ResponseSceneFile;
  7. import lombok.extern.log4j.Log4j2;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.beans.factory.annotation.Value;
  10. import org.springframework.web.bind.annotation.PostMapping;
  11. import org.springframework.web.bind.annotation.RequestMapping;
  12. import org.springframework.web.bind.annotation.RequestParam;
  13. import org.springframework.web.bind.annotation.RestController;
  14. import org.springframework.web.multipart.MultipartFile;
  15. /**
  16. * 场景文件上传模块
  17. */
  18. @Log4j2
  19. @RestController
  20. @RequestMapping("/service/scene/file")
  21. //@Transactional(rollbackFor = Exception.class)
  22. public class SceneFileController extends BaseController {
  23. @Value("${main.url}")
  24. private String mainUrl;
  25. @Value("${scene.url}")
  26. private String sceneUrl;
  27. @Value("${scene.pro.url}")
  28. private String sceneProUrl;
  29. @Value("${scene.pro.new.url}")
  30. private String sceneProNewUrl;
  31. @Value("${upload.type}")
  32. private String type;
  33. @Value("${oss.prefix.ali}")
  34. private String prefixAli;
  35. @Value("${ecs.type}")
  36. private String ecsType;
  37. @Value("${unCalculated.company.ids:#{null}}")
  38. private String[] unCalculatedCompanyIds;
  39. @Autowired
  40. private ISceneFileBuildService sceneFileBuildService;
  41. private String splice = "#";
  42. @Autowired
  43. RedisLockUtil redisLockUtil;
  44. /**
  45. * 场景文件上传之前先获取fileId
  46. * @param params
  47. * @return
  48. * @throws Exception
  49. */
  50. @PostMapping("preUpload")
  51. public ResponseSceneFile preUpload(String params) throws Exception {
  52. return sceneFileBuildService.preUpload(params);
  53. }
  54. /**
  55. * 获取文件上传的状态
  56. * @param params
  57. * @return
  58. * @throws Exception
  59. */
  60. @PostMapping("getProgress")
  61. public ResponseSceneFile getProgress(String params) throws Exception {
  62. return sceneFileBuildService.getProgress(params);
  63. }
  64. /**
  65. * 单个文件上传
  66. * @param file
  67. * @param params
  68. * @return
  69. */
  70. @PostMapping("upload")
  71. public ResultData upload(@RequestParam(value = "file",required = false) MultipartFile file,
  72. String params) throws Exception {
  73. return sceneFileBuildService.uploadFile(file, params);
  74. }
  75. /**
  76. * 上传大文件
  77. * @param file
  78. * @return
  79. * @throws
  80. */
  81. @PostMapping("uploadBigFile")
  82. public ResultData uploadBigFile(@RequestParam(value = "file",required = false) MultipartFile file,
  83. String params) throws Exception {
  84. return sceneFileBuildService.uploadFile(file, params);
  85. }
  86. /**
  87. * 获取亚马逊S3文件上传url
  88. *
  89. * @return
  90. */
  91. @PostMapping("getS3UploadUrl")
  92. public ResultData getS3UploadUrl(String params) throws Exception {
  93. return sceneFileBuildService.getS3UploadUrl(params);
  94. }
  95. }