From f788607ff771a47bc60d6a86e00b3433c40f3d2c Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 24 九月 2021 15:22:03 +0800
Subject: [PATCH] 接入视频直播

---
 src/main/java/com/yeshi/buwan/util/factory/SolrVideoFactory.java |   74 ++++++++++++++++++++++++++++++++++---
 1 files changed, 68 insertions(+), 6 deletions(-)

diff --git a/src/main/java/com/yeshi/buwan/util/factory/SolrVideoFactory.java b/src/main/java/com/yeshi/buwan/util/factory/SolrVideoFactory.java
index 2007f0c..26d1068 100644
--- a/src/main/java/com/yeshi/buwan/util/factory/SolrVideoFactory.java
+++ b/src/main/java/com/yeshi/buwan/util/factory/SolrVideoFactory.java
@@ -1,9 +1,10 @@
 package com.yeshi.buwan.util.factory;
 
-import com.yeshi.buwan.domain.SolrVideo;
 import com.yeshi.buwan.domain.VideoInfo;
 import com.yeshi.buwan.domain.VideoResource;
-import com.yeshi.buwan.util.VideoTypeUtil;
+import com.yeshi.buwan.domain.VideoType;
+import com.yeshi.buwan.domain.solr.SolrAlbumVideo;
+import com.yeshi.buwan.domain.solr.SolrCommonVideo;
 import org.yeshi.utils.StringUtil;
 
 import java.util.ArrayList;
@@ -13,8 +14,55 @@
 public class SolrVideoFactory {
 
 
-    public static SolrVideo create(VideoInfo videoInfo, List<VideoResource> videoResources) {
-        SolrVideo solrVideo = new SolrVideo();
+    public static SolrAlbumVideo createAlbum(VideoInfo videoInfo, List<VideoResource> videoResources) {
+        SolrAlbumVideo solrVideo = new SolrAlbumVideo();
+        solrVideo.setMainactor(videoInfo.getMainActor());
+        solrVideo.setShow(Integer.parseInt(videoInfo.getShow()));
+        solrVideo.setLatestHpicture(videoInfo.getLatestHpicture());
+        solrVideo.setDuration(videoInfo.getDuration());
+        solrVideo.setScore(videoInfo.getScore());
+        solrVideo.setVpicture(videoInfo.getVpicture());
+        solrVideo.setLatestVpicture(videoInfo.getLatestVpicture());
+        solrVideo.setId(videoInfo.getId());
+        solrVideo.setTag(videoInfo.getTag());
+        solrVideo.setHpicture(videoInfo.getHpicture());
+        solrVideo.setArea(videoInfo.getArea());
+        solrVideo.setCreatetime(videoInfo.getCreatetime() + "");
+        solrVideo.setWatchcount(Integer.parseInt(videoInfo.getWatchCount()));
+        solrVideo.setDirector(videoInfo.getDirector());
+        solrVideo.setPicture(videoInfo.getPicture());
+        solrVideo.setContenttype(videoInfo.getContentType());
+        solrVideo.setSolrTime(new Date());
+        solrVideo.setCommentcount(videoInfo.getCommentCount());
+        solrVideo.setVideocount(videoInfo.getVideocount());
+        solrVideo.setName(videoInfo.getName());
+        solrVideo.setNameStr(videoInfo.getName());
+        solrVideo.setUpdatetime(videoInfo.getUpdatetime());
+        if (videoInfo.getUpdatetime() != null)
+            solrVideo.setUpdateTime(Long.parseLong(videoInfo.getUpdatetime()));
+        if (videoInfo.getVideoType() != null)
+            solrVideo.setRootVideoType(videoInfo.getVideoType().getId());
+        else
+            solrVideo.setRootVideoType(0);
+
+        solrVideo.setYear(videoInfo.getYear());
+
+        if (videoResources != null && videoResources.size() > 0) {
+            List<String> resourceIds = new ArrayList<>();
+            for (VideoResource vr : videoResources) {
+                resourceIds.add(vr.getId());
+            }
+            solrVideo.setResourceIds(StringUtil.concat(resourceIds, ","));
+        }
+
+        solrVideo.setFreeType(videoInfo.getFree());
+
+        return solrVideo;
+    }
+
+
+    public static SolrCommonVideo createCommon(VideoInfo videoInfo, List<VideoType> typeList, List<VideoResource> videoResources) {
+        SolrCommonVideo solrVideo = new SolrCommonVideo();
         solrVideo.setMainactor(videoInfo.getMainActor());
         solrVideo.setShow(Integer.parseInt(videoInfo.getShow()));
         solrVideo.setLatestHpicture(videoInfo.getLatestHpicture());
@@ -40,8 +88,20 @@
             solrVideo.setUpdateTime(Long.parseLong(videoInfo.getUpdatetime()));
         if (videoInfo.getVideoType() != null)
             solrVideo.setRootVideoType(videoInfo.getVideoType().getId());
-        else
-            solrVideo.setRootVideoType(0);
+
+        if (typeList != null && typeList.size() > 0) {
+            VideoType videoType = typeList.get(0);
+            if (videoType.getParent() != null) {
+                solrVideo.setRootVideoType(videoType.getParent().getId());
+            } else {
+                solrVideo.setRootVideoType(videoType.getId());
+            }
+            List<Long> ids = new ArrayList<>();
+            for (VideoType cv : typeList) {
+                ids.add(cv.getId());
+            }
+            solrVideo.setVideoTypes(StringUtil.concat(ids, ","));
+        }
 
         solrVideo.setYear(videoInfo.getYear());
 
@@ -55,4 +115,6 @@
 
         return solrVideo;
     }
+
+
 }

--
Gitblit v1.8.0