Kaynağa Gözat

pageUrl上报标题封面

wangyunpeng 1 hafta önce
ebeveyn
işleme
9713ca0956

+ 40 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformPlanServiceImpl.java

@@ -375,6 +375,8 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
                 item.setCover(vo.getCover());
                 setCustomCover(item, vo);
                 item.setCustomCoverType(vo.getCustomCoverType());
+                // 上报多标题封面
+                item.setPageUrl(setMultiTitleCoverPagePath(item));
                 gzhPlanVideoMapper.updateByPrimaryKey(item);
             } else {
                 ContentPlatformGzhPlanVideo item = new ContentPlatformGzhPlanVideo();
@@ -399,6 +401,8 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
                     SmallPageUrlDetail smallPageUrlDetail = json.getJSONObject("data").toJavaObject(SmallPageUrlDetail.class);
                     item.setPageUrl(smallPageUrlDetail.getUrl());
                 }
+                // 上报多标题封面
+                item.setPageUrl(setMultiTitleCoverPagePath(item));
                 item.setCreateAccountId(loginAccount.getId());
                 item.setCreateTimestamp(System.currentTimeMillis());
                 gzhPlanVideoMapper.insert(item);
@@ -409,6 +413,42 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         }
     }
 
+    private String setMultiTitleCoverPagePath(ContentPlatformGzhPlanVideo item) {
+        String pageUrl = item.getPageUrl();
+        if(StringUtils.hasText(pageUrl)){
+            String title = item.getTitle();
+            String cover = item.getCover();
+            try {
+                if (Objects.nonNull(item.getCustomTitleId()) && !pageUrl.contains("shareTitleId")) {
+                    pageUrl += URLEncoder.encode("&shareTitleId=" + item.getCustomTitleId(), "UTF-8");
+                }
+                if (!pageUrl.contains("shareTitle")) {
+                    if (StringUtils.hasText(item.getCustomTitle())) {
+                        pageUrl += URLEncoder.encode("&shareTitle=" + item.getCustomTitle(), "UTF-8");
+                        title = item.getCustomTitle();
+                    } else {
+                        pageUrl += URLEncoder.encode("&shareTitle=" + item.getTitle(), "UTF-8");
+                    }
+                }
+                if (Objects.nonNull(item.getCustomCoverId()) && !pageUrl.contains("shareImageId")) {
+                    pageUrl += URLEncoder.encode("&shareImageId=" + item.getCustomCoverId(), "UTF-8");
+                }
+                if (!pageUrl.contains("shareImageUrl")) {
+                    if (StringUtils.hasText(item.getCustomCover())) {
+                        pageUrl += URLEncoder.encode("&shareImageUrl=" + URLEncoder.encode(item.getCustomCover(), "UTF-8"), "UTF-8");
+                        cover = item.getCustomCover();
+                    } else {
+                        pageUrl += URLEncoder.encode("&shareImageUrl=" + URLEncoder.encode(item.getCover(), "UTF-8"), "UTF-8");
+                    }
+                }
+            } catch (Exception e) {
+                log.error("设置视频多标题封面失败,videoId={}", item.getVideoId(), e);
+            }
+            pageUrl = videoMultiService.setVideoMultiTitleCoverPagePath(item.getVideoId(), pageUrl, title, cover);
+        }
+        return pageUrl;
+    }
+
     private void setCustomTitle(ContentPlatformGzhPlanVideo item, GzhPlanVideoContentItemParam vo) {
         if (StringUtils.hasText(vo.getCustomTitle())) {
             List<ContentPlatformGzhPlanVideo> gzhPlanVideoList = gzhPlanVideoListByVideoTitle(vo.getVideoId());

+ 12 - 0
api-module/src/test/java/com/tzld/piaoquan/api/GhDetailTest.java

@@ -11,6 +11,7 @@ import com.tzld.piaoquan.growth.common.dao.mapper.CgiReplyBucketDataMapper;
 import com.tzld.piaoquan.growth.common.dao.mapper.ext.CgiReplyBucketDataMapperExt;
 import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData;
 import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketDataExample;
+import com.tzld.piaoquan.growth.common.utils.MessageUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.junit.jupiter.api.Test;
@@ -118,4 +119,15 @@ public class GhDetailTest {
         }
     }
 
+    @Test
+    public void setRootSourceId() {
+        CgiReplyBucketDataExample example = new CgiReplyBucketDataExample();
+        example.createCriteria().andRootSourceIdIsNull();
+        List<CgiReplyBucketData> list = cgiReplyBucketDataMapper.selectByExample(example);
+        for (CgiReplyBucketData item : list) {
+            item.setRootSourceId(MessageUtil.getRootSourceId(item.getMiniPagePath()));
+            cgiReplyBucketDataMapper.updateByPrimaryKeySelective(item);
+        }
+    }
+
 }