Browse Source

Merge branch 'master' of http://gogs.efunbox.cn:3000/Rankin/rankin

xuchaolang 6 years ago
parent
commit
4f2db3edf5

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

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

+ 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 - 5
rankin-product-service/src/main/java/cn/rankin/productservice/controller/TagTypeController.java

@@ -92,18 +92,15 @@ public class TagTypeController {
     }
 
     @RequestMapping(value = "/{tagTypeId}", method = RequestMethod.GET)
-    public APIResult<TagType> getTagType(@PathVariable("tagTypeId") String tagTypeId, @RequestParam("merchantId") String merchantId) {
+    public APIResult<TagType> getTagType(@PathVariable("tagTypeId") String tagTypeId) {
         TagType tagType = tagTypeService.getTagType(tagTypeId);
 
         if (tagType == null) {
             return APIResult.error(ProductServiceAPICode.NOT_EXISTS);
         }else{
-
             //开始组装数据
-            List<Tag> tagList = tagService.findByTypeCode(tagType.getCode(),merchantId);
+            List<Tag> tagList = tagService.findByTypeCode(tagType.getCode());
             tagType.setTagList(tagList);
-
-
             return APIResult.ok(tagType);
         }
 

+ 3 - 0
rankin-product-service/src/main/java/cn/rankin/productservice/repository/TagRepository.java

@@ -21,6 +21,9 @@ public interface TagRepository extends BasicJpaRepository<Tag, String> {
     @Query(value = "select t from Tag t where t.typeCode = ?1 and t.merchantId = ?2 order by t.sort")
     List<Tag> findByTypeCode(String typeCode,String merchantId);
 
+    @Query(value = "select t from Tag t where t.typeCode = ?1 order by t.sort")
+    List<Tag> findByTypeCode(String typeCode);
+
     @Query(value = "select t from Tag t where t.id in (?1) and t.status = ?2")
     List<Tag> findByIds(List<String> tagIdList, BaseStatusEnum status);
 

+ 5 - 0
rankin-product-service/src/main/java/cn/rankin/productservice/service/TagService.java

@@ -57,6 +57,11 @@ public class TagService {
         return tagList;
     }
 
+    public List<Tag> findByTypeCode(String typeCode) {
+        List<Tag> tagList = tagRepository.findByTypeCode(typeCode);
+        return tagList;
+    }
+
 
     public void setGroupInfo(List<Tag> tagList) {
         if (CollectionUtils.isEmpty(tagList)) return;

+ 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);
     }
 
 }