|
@@ -11,6 +11,7 @@ import cn.rankin.common.utils.exception.UnsupportedOperationException;
|
|
import cn.rankin.resourceservice.dto.ResourceDetail;
|
|
import cn.rankin.resourceservice.dto.ResourceDetail;
|
|
import cn.rankin.resourceservice.dto.ResourceRemote;
|
|
import cn.rankin.resourceservice.dto.ResourceRemote;
|
|
import cn.rankin.data.api.resource.entity.Resource;
|
|
import cn.rankin.data.api.resource.entity.Resource;
|
|
|
|
+import cn.rankin.resourceservice.dto.ResourceVideo;
|
|
import cn.rankin.resourceservice.proxy.RemoteResourceProxy;
|
|
import cn.rankin.resourceservice.proxy.RemoteResourceProxy;
|
|
import cn.rankin.resourceservice.repository.ResourceRepository;
|
|
import cn.rankin.resourceservice.repository.ResourceRepository;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -19,10 +20,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.StringUtils;
|
|
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
|
|
@Slf4j
|
|
@@ -243,9 +241,9 @@ public class ResourceService {
|
|
*/
|
|
*/
|
|
public APIResult<Resource> saveRemoteResource(Resource resource) {
|
|
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<>();
|
|
Map<String, Object> video = new HashMap<>();
|
|
- video.put("bucket","");
|
|
|
|
|
|
+ video.put("bucket","efunbox");
|
|
video.put("path",resource.getPath());
|
|
video.put("path",resource.getPath());
|
|
video.put("format",resource.getFormat());
|
|
video.put("format",resource.getFormat());
|
|
video.put("quality",resource.getQuality());
|
|
video.put("quality",resource.getQuality());
|
|
@@ -253,6 +251,7 @@ public class ResourceService {
|
|
|
|
|
|
videos.add(video);
|
|
videos.add(video);
|
|
|
|
|
|
|
|
+
|
|
APIResult<ResourceDetail> apiResult = resourceProxy.saveResources(new HashMap<String, Object>(){
|
|
APIResult<ResourceDetail> apiResult = resourceProxy.saveResources(new HashMap<String, Object>(){
|
|
{
|
|
{
|
|
this.put("no", resource.getCode());
|
|
this.put("no", resource.getCode());
|
|
@@ -262,15 +261,40 @@ 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);
|
|
|
|
+ log.info("saveResources: "+apiResult);
|
|
|
|
+ log.info("Remote Server return: code={}, message={}", apiResult.getCode(), apiResult.getMessage());
|
|
if (!apiResult.getSuccess()) {
|
|
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);
|
|
|
|
|
|
+// Resource resourceVO = apiResult.getData().toNativeResource();
|
|
|
|
+ return APIResult.ok();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -281,17 +305,18 @@ public class ResourceService {
|
|
public APIResult<Resource> updateRemoteResource(Resource resource) {
|
|
public APIResult<Resource> updateRemoteResource(Resource resource) {
|
|
|
|
|
|
APIResult<ResourceRemote> result = resourceProxy.findById(resource.getId());
|
|
APIResult<ResourceRemote> result = resourceProxy.findById(resource.getId());
|
|
|
|
+ log.info("Remote Server info: code={}, message={},data={}", result.getCode(), result.getMessage(),result.getData());
|
|
if (!result.getSuccess()) {
|
|
if (!result.getSuccess()) {
|
|
log.error("Remote Server Error: code={}, message={}", result.getCode(), result.getMessage());
|
|
log.error("Remote Server Error: code={}, message={}", result.getCode(), result.getMessage());
|
|
APIResult errResult = APIResult.error(APICode.REMOTE_SERVER_ERROR);
|
|
APIResult errResult = APIResult.error(APICode.REMOTE_SERVER_ERROR);
|
|
- result.setMessage(result.getMessage());
|
|
|
|
|
|
+ errResult.setMessage(result.getMessage());
|
|
return errResult;
|
|
return errResult;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- List<Map<String, Object>> videos = new ArrayList<>();
|
|
|
|
|
|
+/* List<Map<String, Object>> videos = new ArrayList<>();
|
|
Map<String, Object> video = new HashMap<>();
|
|
Map<String, Object> video = new HashMap<>();
|
|
- video.put("bucket","");
|
|
|
|
|
|
+ video.put("bucket","efunbox");
|
|
video.put("path",resource.getPath());
|
|
video.put("path",resource.getPath());
|
|
video.put("format",resource.getFormat());
|
|
video.put("format",resource.getFormat());
|
|
video.put("quality",resource.getQuality());
|
|
video.put("quality",resource.getQuality());
|
|
@@ -307,17 +332,54 @@ public class ResourceService {
|
|
this.put("type", "1");
|
|
this.put("type", "1");
|
|
this.put("videos", videos);
|
|
this.put("videos", videos);
|
|
}
|
|
}
|
|
- });
|
|
|
|
|
|
+ });*/
|
|
|
|
+
|
|
|
|
+ Set<ResourceVideo> videos = result.getData().getVideos();
|
|
|
|
+ if(videos != null && videos.size() > 0){
|
|
|
|
+ Iterator<ResourceVideo> iterator = videos.iterator();
|
|
|
|
+ while(iterator.hasNext()){
|
|
|
|
+ ResourceVideo video = iterator.next();
|
|
|
|
+ video.setBucket("efunbox");
|
|
|
|
+ video.setPath(resource.getPath());
|
|
|
|
+ video.setQuality(resource.getQuality());
|
|
|
|
+ video.setFormat(resource.getFormat());
|
|
|
|
+ video.setSize(resource.getSize());
|
|
|
|
+ log.info("Remote Server info: video={}, message={},data={}", video);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+/* 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);
|
|
|
|
+ log.info("updateResources: "+apiResult);
|
|
if (!apiResult.getSuccess()) {
|
|
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();
|
|
|
|
+ }
|
|
|
|
|
|
- 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;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|