xueyiming 3 mesi fa
parent
commit
decee4edca

+ 20 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/common/enums/TransformationEnum.java

@@ -0,0 +1,20 @@
+package com.tzld.piaoquan.longarticle.common.enums;
+
+import lombok.Getter;
+
+@Getter
+public enum TransformationEnum {
+
+    NOT_EXIST(0, "不存在片尾引导"),
+    EXIST(1, "存在片尾引导");
+
+    private final int type;
+    private final String desc;
+
+    TransformationEnum(int type, String desc) {
+        this.type = type;
+        this.desc = desc;
+    }
+
+
+}

+ 16 - 11
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/ContentServiceImpl.java

@@ -6,6 +6,7 @@ import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 import com.tzld.piaoquan.longarticle.common.enums.ContentStatusEnum;
 import com.tzld.piaoquan.longarticle.common.enums.PublicFlagEnum;
 import com.tzld.piaoquan.longarticle.common.enums.PublishGzhPushTypeEnum;
+import com.tzld.piaoquan.longarticle.common.enums.TransformationEnum;
 import com.tzld.piaoquan.longarticle.dao.mapper.longarticle.*;
 import com.tzld.piaoquan.longarticle.model.bo.VideoDetail;
 import com.tzld.piaoquan.longarticle.model.dto.ArticleSortRequest;
@@ -260,20 +261,23 @@ public class ContentServiceImpl implements ContentService {
         SingleVideoSource singleVideoSource = singleVideoSources.get(0);
         String ossPath = singleVideoSource.getVideoOssPath();
         String title = singleVideoSource.getMiniProgramTitle();
-        int transformationType = 0;
+        //是否存在片尾引导
+        int transformationType;
         int publishType = 0;
         String videoOriginType = "video_pool";
         Long videoOriginId = (long) singleVideoSource.getId();
         VideoEndScreen videoEndScreen = existVideoEndScreen(videoOriginId, videoOriginType);
         //查询到改写的视频  随机选择原视频或者改写后的视频
         if (videoEndScreen != null) {
-            transformationType = 1;
-            int random = ToolUtil.getRandom(2);
-            if (random == 1) {
+            transformationType = TransformationEnum.EXIST.getType();
+            //存在片尾引导后  50%概率走有片尾引导的视频
+            publishType = ToolUtil.getRandom(2);
+            if (publishType == 1) {
                 ossPath = videoEndScreen.getNewOssPath();
                 title = videoEndScreen.getTitle();
-                publishType = 1;
             }
+        } else {
+            transformationType = TransformationEnum.NOT_EXIST.getType();
         }
         VideoDetail videoDetail = videoService.publish(ossPath,
                 SINGLE_VIDEO_UID, title);
@@ -306,20 +310,21 @@ public class ContentServiceImpl implements ContentService {
                 continue;
             }
             String title = kimiText.getKimiTitle();
-            int transformationType = 0;
+            int transformationType;
             int publishType = 0;
             String videoOriginType = "long_article";
             Long videoOriginId = (long) crawlerVideoId;
             VideoEndScreen videoEndScreen = existVideoEndScreen(videoOriginId, videoOriginType);
             //查询到改写的视频  随机选择原视频或者改写后的视频
             if (videoEndScreen != null) {
-                transformationType = 1;
-                int random = ToolUtil.getRandom(2);
-                if (random == 1) {
+                transformationType = TransformationEnum.EXIST.getType();
+                publishType = ToolUtil.getRandom(2);
+                if (publishType == 1) {
                     videoOssPath = videoEndScreen.getNewOssPath();
                     title = videoEndScreen.getTitle();
-                    publishType = 1;
                 }
+            } else {
+                transformationType = TransformationEnum.NOT_EXIST.getType();
             }
             VideoDetail videoDetail = videoService.publish(videoOssPath, userId, title);
             if (videoDetail == null) {
@@ -389,7 +394,7 @@ public class ContentServiceImpl implements ContentService {
     }
 
     public void logEvent(String videoOriginType, Long videoOriginId, String videoId,
-                    int transformationType, int publishType) {
+                         int transformationType, int publishType) {
         JSONObject jsonObject = new JSONObject();
         jsonObject.put("code", "changwen_video_publish");
         JSONObject data = new JSONObject();

+ 1 - 1
long-article-server/src/main/resources/application-test.properties

@@ -15,7 +15,7 @@ spring.redis.password=Qingqu2019
 
 apollo.meta: https://apolloconfig-internal.piaoquantv.com
 
-xxl.job.admin.addresses=http://xxl-job-internal.piaoquantv.com/xxl-job-admin
+xxl.job.admin.addresses=http://test-xxl-job-internal.piaoquantv.com/xxl-job-admin
 
 download.path=/Users/shimeng/Desktop/download/