Browse Source

fix saveRemoteResource

guozhaoshun 6 years ago
parent
commit
776686cff5

+ 2 - 2
rankin-resource-service/src/main/java/cn/rankin/resourceservice/proxy/RemoteResourceProxy.java

@@ -32,9 +32,9 @@ public interface RemoteResourceProxy {
     APIResult<List<ResourceDetail>> getBatch(@RequestParam("ids") List<String> ids);
 
     @RequestMapping(value = "/rcenter/v1/resources/mgt", method = RequestMethod.POST)
-    APIResult<ResourceDetail> saveResources(@RequestParam ResourceRemote resourceRemote);
+    APIResult<ResourceDetail> saveResources(@RequestParam Map<String, Object> map);
 
     @RequestMapping(value = "/rcenter/v1/resources/mgt", method = RequestMethod.PUT)
-    APIResult<ResourceDetail> updateResources(@RequestParam ResourceRemote resourceRemote);
+    APIResult<ResourceDetail> updateResources(@RequestParam Map<String, Object> map);
 
 }

+ 22 - 39
rankin-resource-service/src/main/java/cn/rankin/resourceservice/service/ResourceService.java

@@ -11,7 +11,6 @@ import cn.rankin.common.utils.exception.UnsupportedOperationException;
 import cn.rankin.resourceservice.dto.ResourceDetail;
 import cn.rankin.resourceservice.dto.ResourceRemote;
 import cn.rankin.data.api.resource.entity.Resource;
-import cn.rankin.resourceservice.dto.ResourceVideo;
 import cn.rankin.resourceservice.proxy.RemoteResourceProxy;
 import cn.rankin.resourceservice.repository.ResourceRepository;
 import lombok.extern.slf4j.Slf4j;
@@ -20,7 +19,10 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 
 @Slf4j
@@ -241,7 +243,6 @@ public class ResourceService {
      */
     public APIResult<Resource> saveRemoteResource(Resource resource) {
 
-        /*
         List<Map<String, Object>> videos = new ArrayList<>();
         Map<String, Object> video = new HashMap<>();
         video.put("bucket","efunbox");
@@ -251,25 +252,15 @@ public class ResourceService {
         video.put("size",resource.getSize());
 
         videos.add(video);
-        */
-
-        Set<ResourceVideo> videos = new HashSet<>();
-        ResourceVideo video = new ResourceVideo();
-        video.setQuality(resource.getQuality());
-        video.setFormat(resource.getFormat());
-        video.setBucket("efunbox");
-        video.setSize(resource.getSize());
-        video.setPath(resource.getPath());
-        videos.add(video);
-
 
-        ResourceRemote resourceRemote = new ResourceRemote();
-        resourceRemote.setNo(resource.getCode());
-        resourceRemote.setTitle(resource.getName());
-        resourceRemote.setType(resource.getType());
-        resourceRemote.setVideos(videos);
-
-        APIResult<ResourceDetail> apiResult = resourceProxy.saveResources(resourceRemote);
+        APIResult<ResourceDetail> apiResult = resourceProxy.saveResources(new HashMap<String, Object>(){
+            {
+                this.put("no", resource.getCode());
+                this.put("title", resource.getName());
+                this.put("type", resource.getType());
+                this.put("videos", videos);
+            }
+        });
 
         if (!apiResult.getSuccess()) {
             return errorResourceAPIResult(apiResult);
@@ -295,7 +286,7 @@ public class ResourceService {
         }
 
 
-      /*  List<Map<String, Object>> videos = new ArrayList<>();
+        List<Map<String, Object>> videos = new ArrayList<>();
         Map<String, Object> video = new HashMap<>();
         video.put("bucket","efunbox");
         video.put("path",resource.getPath());
@@ -303,25 +294,17 @@ public class ResourceService {
         video.put("quality",resource.getQuality());
         video.put("size",resource.getSize());
 
-        videos.add(video);*/
-
-        Set<ResourceVideo> videos = new HashSet<>();
-        ResourceVideo video = new ResourceVideo();
-        video.setQuality(resource.getQuality());
-        video.setFormat(resource.getFormat());
-        video.setBucket("efunbox");
-        video.setSize(resource.getSize());
-        video.setPath(resource.getPath());
         videos.add(video);
 
-
-        ResourceRemote resourceRemote = new ResourceRemote();
-        resourceRemote.setNo(resource.getCode());
-        resourceRemote.setTitle(resource.getName());
-        resourceRemote.setType(resource.getType());
-        resourceRemote.setVideos(videos);
-
-        APIResult<ResourceDetail> apiResult = resourceProxy.updateResources(resourceRemote);
+        APIResult<ResourceDetail> apiResult = resourceProxy.updateResources(new HashMap<String, Object>(){
+            {
+                this.put("id", resource.getId());
+                this.put("no", resource.getCode());
+                this.put("title", resource.getName());
+                this.put("type", "1");
+                this.put("videos", videos);
+            }
+        });
 
         if (!apiResult.getSuccess()) {
             return errorResourceAPIResult(apiResult);