Browse Source

add support video create/update

guozhaoshun 6 years ago
parent
commit
c255956683

+ 2 - 2
rankin-cms-web/src/main/java/cn/rankin/cmsweb/controller/product/TagTypeController.java

@@ -49,10 +49,10 @@ public class TagTypeController {
     }
 
 
-/*    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
+    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
     public APIResult<TagTypeVo> getTagType(@PathVariable("id") String id) {
         return tagTypeServiceInterface.getTagType(id);
-    }*/
+    }
 
 /*    @RequestMapping(value = "/code/{typeCode}", method = RequestMethod.GET)
     public APIResult<List<TagVo>> getTagTypeByCode(@PathVariable("typeCode") String typeCode) {

+ 2 - 2
rankin-cms-web/src/main/resources/bootstrap.yml

@@ -3,9 +3,9 @@ spring:
     name: cms-web
   cloud:
     config:
-      uri: http://config.rankin.com:8921
+      uri: http://127.0.0.1:8921
       label: master
-      profile: ${profile:dev}
+      profile: ${profile:local}
 
 feign:
   httpclient:

+ 2 - 2
rankin-config-service/src/main/resources/bootstrap.yml

@@ -5,8 +5,8 @@ spring:
     config:
       server:
         git:
-          uri: http://gogs.efunbox.cn:3000/Rankin/setting.git
-          search-paths: dev, prod
+          uri: https://gitee.com/guozhaoshun/project-config.git
+          search-paths: dev, prod ,local
 
 server:
   port: 8921

+ 1 - 1
rankin-eureka-service/src/main/resources/bootstrap.yml

@@ -3,7 +3,7 @@ server:
 
 eureka:
   instance:
-    hostname: discovery.rankin.com
+    hostname: 127.0.0.1
   server:
     enable-self-preservation: false
   client:

+ 0 - 3
rankin-product-service/src/main/java/cn/rankin/productservice/controller/TagTypeController.java

@@ -98,12 +98,9 @@ public class TagTypeController {
         if (tagType == null) {
             return APIResult.error(ProductServiceAPICode.NOT_EXISTS);
         }else{
-
             //开始组装数据
             List<Tag> tagList = tagService.findByTypeCode(tagType.getCode(),merchantId);
             tagType.setTagList(tagList);
-
-
             return APIResult.ok(tagType);
         }
 

+ 2 - 2
rankin-product-service/src/main/resources/bootstrap.yml

@@ -3,9 +3,9 @@ spring:
     name: product-service
   cloud:
     config:
-      uri: http://config.rankin.com:8921
+      uri: http://127.0.0.1:8921
       label: master
-      profile: ${profile:dev}
+      profile: ${profile:local}
 
 server:
   port: 8100

+ 7 - 1
rankin-resource-service/src/main/java/cn/rankin/resourceservice/controller/ResourceController.java

@@ -88,7 +88,13 @@ public class ResourceController {
 
     @RequestMapping(value="/{id}", method = RequestMethod.PUT)
     public APIResult<Resource> update(@PathVariable("id") String id, @RequestBody Resource resource) {
-        resourceService.update(resource);
+        if(resource.getType().intValue() == ResourceType.VIDEO){
+            //视频类型   存远程资源库
+            return  resourceService.updateRemoteResource(resource);
+        }else{
+            resourceService.update(resource);
+        }
+
         return APIResult.ok();
     }
 }

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

@@ -22,6 +22,9 @@ public interface RemoteResourceProxy {
     @RequestMapping(value = "rcenter/v1/resources/no/{code}", method = RequestMethod.GET)
     APIResult<ResourceRemote> findByCode(@PathVariable("code") String code);
 
+    @RequestMapping(value = "rcenter/v1/resources/{id}", method = RequestMethod.GET)
+    APIResult<ResourceRemote> findById(@PathVariable("id") String id);
+
 //    @RequestMapping(value = "rcenter/v1/resources", method = RequestMethod.GET)
 //    APIResult<List<ResourceRemote>> getBatch(@RequestParam("ids") List<String> ids);
 
@@ -31,4 +34,7 @@ public interface RemoteResourceProxy {
     @RequestMapping(value = "/rcenter/v1/resources/mgt", method = RequestMethod.POST)
     APIResult<ResourceDetail> saveResources(@RequestParam Map<String, Object> map);
 
+    @RequestMapping(value = "/rcenter/v1/resources/mgt", method = RequestMethod.PUT)
+    APIResult<ResourceDetail> updateResources(@RequestParam Map<String, Object> map);
+
 }

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

@@ -236,7 +236,8 @@ public class ResourceService {
     }
 
     /**
-     * upload  ViDEO
+     * saveRemoteResource
+     * type 0 video , 1 audio
      * @param resource
      * @return
      */
@@ -268,8 +269,55 @@ public class ResourceService {
             return errResult;
         }
 
-        Resource result = apiResult.getData().toNativeResource();
-        return APIResult.ok(result);
+        Resource resourceVO = apiResult.getData().toNativeResource();
+        return APIResult.ok(resourceVO);
+    }
+
+    /**
+     * update  RemoteResource
+     * @param resource
+     * @return
+     */
+    public APIResult<Resource> updateRemoteResource(Resource resource) {
+
+        APIResult<ResourceRemote> result = resourceProxy.findById(resource.getId());
+        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());
+            return errResult;
+        }
+
+
+        List<Map<String, Object>> videos = new ArrayList<>();
+        Map<String, Object> video = new HashMap<>();
+        video.put("bucket","");
+        video.put("path",resource.getPath());
+        video.put("format",resource.getFormat());
+        video.put("quality",resource.getQuality());
+        video.put("size",resource.getSize());
+
+        videos.add(video);
+
+        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()) {
+            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;
+        }
+
+        Resource resourceVO = apiResult.getData().toNativeResource();
+        return APIResult.ok(resourceVO);
     }
 
 }

+ 2 - 2
rankin-resource-service/src/main/resources/bootstrap.yml

@@ -3,9 +3,9 @@ spring:
     name: resource-service
   cloud:
     config:
-      uri: http://config.rankin.com:8921
+      uri: http://127.0.0.1:8921
       label: master
-      profile: ${profile:dev}
+      profile: ${profile:local}
 
 server:
   port: 8200

+ 2 - 2
rankin-task/src/main/resources/bootstrap.yml

@@ -3,9 +3,9 @@ spring:
     name: rankin-task
   cloud:
     config:
-      uri: http://config.rankin.com:8921
+      uri: http://127.0.0.1:8921
       label: master
-      profile: ${profile:dev}
+      profile: ${profile:local}
 
 feign:
   httpclient:

+ 2 - 2
rankin-trade-service/src/main/resources/bootstrap.yml

@@ -3,9 +3,9 @@ spring:
     name: trade-service
   cloud:
     config:
-      uri: http://config.rankin.com:8921
+      uri: http://127.0.0.1:8921
       label: master
-      profile: ${profile:dev}
+      profile: ${profile:local}
 
 server:
   port: 8300

+ 2 - 2
rankin-user-service/src/main/resources/bootstrap.yml

@@ -5,9 +5,9 @@ spring:
     active:
   cloud:
     config:
-      uri: http://config.rankin.com:8921
+      uri: http://127.0.0.1:8921
       label: master
-      profile: ${profile:dev}
+      profile: ${profile:local}
 
 #logging:
 #  level: