Преглед изворни кода

optimize change video resource url | https://

guozhaoshun пре 6 година
родитељ
комит
addf733cef

+ 3 - 0
rankin-resource-service/src/main/java/cn/rankin/resourceservice/controller/ResourceController.java

@@ -24,6 +24,9 @@ public class ResourceController {
     @Autowired
     private ResourceService resourceService;
 
+    public static String HTTP_VIDEO_DOMAIN = "http://efunvideo.ai160.com";
+    public static String LJ_VIDEO_DOMAIN = "http://ljvideo.ai160.com";
+
     @RequestMapping(value = "/list")
     public APIResult<Page<Resource>> search(ResourceSearchDTO resourceSearchDTO) {
         log.info(JSON.toJSONString(resourceSearchDTO));

+ 9 - 2
rankin-resource-service/src/main/java/cn/rankin/resourceservice/dto/ResourceDetail.java

@@ -3,10 +3,13 @@ package cn.rankin.resourceservice.dto;
 import cn.rankin.common.utils.enums.BaseStatusEnum;
 import cn.rankin.data.api.resource.entity.Resource;
 import cn.rankin.common.utils.constant.ResourceType;
+import cn.rankin.resourceservice.controller.ResourceController;
 import lombok.Data;
 import lombok.ToString;
 import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
 
+import javax.persistence.Transient;
 import java.io.Serializable;
 import java.util.Date;
 
@@ -44,6 +47,10 @@ public class ResourceDetail implements Serializable {
     // 类型
     private Integer dataRate;
 
+    @Value("${resource.video.domain}")
+    @Transient
+    private String videoDomain;
+
     public Resource toNativeResource() {
         if (type.intValue() == ResourceType.AUDIO) {
             return toNativeAudio();
@@ -60,8 +67,8 @@ public class ResourceDetail implements Serializable {
         resource.setName(title);
         resource.setType(type);
         if(StringUtils.isNotBlank(fullPath)){
-            resource.setUrl(fullPath.replace("http://efunvideo.ai160.com","https://efunvideo.ai160.com")
-                                    .replace("http://ljvideo.ai160.com","https://efunvideo.ai160.com"));
+            resource.setUrl(fullPath.replace(ResourceController.HTTP_VIDEO_DOMAIN, videoDomain)
+                                    .replace(ResourceController.LJ_VIDEO_DOMAIN, videoDomain));
         }else{
             resource.setUrl(fullPath);
         }

+ 8 - 2
rankin-resource-service/src/main/java/cn/rankin/resourceservice/dto/ResourceRemote.java

@@ -7,8 +7,10 @@ import javax.persistence.*;
 import cn.rankin.common.utils.enums.BaseStatusEnum;
 import cn.rankin.data.api.resource.entity.Resource;
 import cn.rankin.common.utils.constant.ResourceType;
+import cn.rankin.resourceservice.controller.ResourceController;
 import lombok.Data;
 import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
 
 @Data
 public class ResourceRemote implements Serializable {
@@ -42,6 +44,10 @@ public class ResourceRemote implements Serializable {
     @Transient
     private Set<ResourceAudio> audios = new HashSet<ResourceAudio>();
 
+    @Value("${resource.video.domain}")
+    @Transient
+    private String videoDomain;
+
     public List<Resource> toNativeResource() {
         if (type == null) {
             return new ArrayList<>();
@@ -66,8 +72,8 @@ public class ResourceRemote implements Serializable {
             resource.setType(type);
             if(StringUtils.isNotBlank(v.getFullPath())){
                 resource.setUrl(v.getFullPath()
-                                .replace("http://efunvideo.ai160.com","https://efunvideo.ai160.com")
-                                .replace("http://ljvideo.ai160.com","https://efunvideo.ai160.com"));
+                                .replace(ResourceController.HTTP_VIDEO_DOMAIN, videoDomain)
+                                .replace(ResourceController.LJ_VIDEO_DOMAIN, videoDomain));
             }else{
                 resource.setUrl(v.getFullPath());
             }