Browse Source

fix saveRemoteResource

guozhaoshun 6 years ago
parent
commit
64dfcc4709

+ 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 Map<String, Object> map);
+    APIResult<ResourceDetail> saveResources(@RequestParam("resourceRemote") ResourceRemote resourceRemote);
 
     @RequestMapping(value = "/rcenter/v1/resources/mgt", method = RequestMethod.PUT)
-    APIResult<ResourceDetail> updateResources(@RequestParam Map<String, Object> map);
+    APIResult<ResourceDetail> updateResources(@RequestParam("resourceRemote") ResourceRemote resourceRemote);
 
 }

+ 51 - 7
rankin-resource-service/src/main/java/cn/rankin/resourceservice/service/ResourceService.java

@@ -11,6 +11,7 @@ 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;
@@ -19,10 +20,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 
 @Slf4j
@@ -243,7 +241,7 @@ public class ResourceService {
      */
     public APIResult<Resource> saveRemoteResource(Resource resource) {
 
-        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());
@@ -253,6 +251,7 @@ public class ResourceService {
 
         videos.add(video);
 
+
         APIResult<ResourceDetail> apiResult = resourceProxy.saveResources(new HashMap<String, Object>(){
             {
                 this.put("no", resource.getCode());
@@ -262,6 +261,33 @@ public class ResourceService {
             }
         });
 
+
+
+
+
+        */
+
+        Set<ResourceVideo> videos = new HashSet<>();
+        ResourceVideo video = new ResourceVideo();
+        video.setBucket("efunbox");
+        video.setPath(resource.getPath());
+        video.setQuality(resource.getQuality());
+        video.setFormat(resource.getFormat());
+        video.setSize(resource.getSize());
+        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);
+
         if (!apiResult.getSuccess()) {
             return errorResourceAPIResult(apiResult);
         }
@@ -286,7 +312,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());
@@ -304,7 +330,25 @@ public class ResourceService {
                 this.put("type", "1");
                 this.put("videos", videos);
             }
-        });
+        });*/
+
+        Set<ResourceVideo> videos = new HashSet<>();
+        ResourceVideo video = new ResourceVideo();
+        video.setBucket("efunbox");
+        video.setPath(resource.getPath());
+        video.setQuality(resource.getQuality());
+        video.setFormat(resource.getFormat());
+        video.setSize(resource.getSize());
+        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);
 
         if (!apiResult.getSuccess()) {
             return errorResourceAPIResult(apiResult);