ソースを参照

fix saveRemoteResource

guozhaoshun 6 年 前
コミット
a43d1f19e8

+ 12 - 11
rankin-resource-service/src/main/java/cn/rankin/resourceservice/service/ResourceService.java

@@ -245,7 +245,7 @@ public class ResourceService {
 
         List<Map<String, Object>> videos = new ArrayList<>();
         Map<String, Object> video = new HashMap<>();
-        video.put("bucket",resource.getName());
+        video.put("bucket","efunbox");
         video.put("path",resource.getPath());
         video.put("format",resource.getFormat());
         video.put("quality",resource.getQuality());
@@ -263,10 +263,7 @@ public class ResourceService {
         });
 
         if (!apiResult.getSuccess()) {
-            log.error("Remote Server Error: code={}, message={}", apiResult.getCode(), apiResult.getMessage());
-            APIResult errResult = APIResult.error(APICode.REMOTE_SERVER_ERROR);
-            apiResult.setMessage(apiResult.getMessage());
-            return errResult;
+            return errorResourceAPIResult(apiResult);
         }
 
         Resource resourceVO = apiResult.getData().toNativeResource();
@@ -284,14 +281,14 @@ public class ResourceService {
         if (!result.getSuccess()) {
             log.error("Remote Server Error: code={}, message={}", result.getCode(), result.getMessage());
             APIResult errResult = APIResult.error(APICode.REMOTE_SERVER_ERROR);
-            result.setMessage(result.getMessage());
+            errResult.setMessage(result.getMessage());
             return errResult;
         }
 
 
         List<Map<String, Object>> videos = new ArrayList<>();
         Map<String, Object> video = new HashMap<>();
-        video.put("bucket","");
+        video.put("bucket","efunbox");
         video.put("path",resource.getPath());
         video.put("format",resource.getFormat());
         video.put("quality",resource.getQuality());
@@ -310,15 +307,19 @@ public class ResourceService {
         });
 
         if (!apiResult.getSuccess()) {
-            log.error("Remote Server Error: code={}, message={}", apiResult.getCode(), apiResult.getMessage());
-            APIResult errResult = APIResult.error(APICode.REMOTE_SERVER_ERROR);
-            apiResult.setMessage(apiResult.getMessage());
-            return errResult;
+            return errorResourceAPIResult(apiResult);
         }
 
         Resource resourceVO = apiResult.getData().toNativeResource();
         return APIResult.ok(resourceVO);
     }
 
+    private APIResult<Resource> errorResourceAPIResult(APIResult<ResourceDetail> apiResult) {
+        log.error("Remote Server Error: code={}, message={}", apiResult.getCode(), apiResult.getMessage());
+        APIResult errResult = APIResult.error(APICode.REMOTE_SERVER_ERROR);
+        errResult.setMessage(apiResult.getMessage());
+        return errResult;
+    }
+
 }