From 4011b8d0b377af33e2bc435f7726329630d706cb Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 02 三月 2021 18:28:52 +0800
Subject: [PATCH] 搜索引擎接口更新

---
 src/main/java/com/yeshi/buwan/service/imp/juhe/FunTV2ServiceImpl.java |   74 ++++++++++++++++++------------------
 1 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/src/main/java/com/yeshi/buwan/service/imp/juhe/FunTV2ServiceImpl.java b/src/main/java/com/yeshi/buwan/service/imp/juhe/FunTV2ServiceImpl.java
index 8eccadd..95396ff 100644
--- a/src/main/java/com/yeshi/buwan/service/imp/juhe/FunTV2ServiceImpl.java
+++ b/src/main/java/com/yeshi/buwan/service/imp/juhe/FunTV2ServiceImpl.java
@@ -24,6 +24,7 @@
 import com.yeshi.buwan.service.inter.juhe.FunTV2Service;
 import com.yeshi.buwan.util.mq.CMQManager;
 import com.yeshi.buwan.util.video.VideoConstant;
+import com.yeshi.buwan.vo.AcceptData;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -151,29 +152,45 @@
         FunTVAlbum2 album2 = funTVAlbum2Dao.get(id);
         if (album2 == null)
             return null;
-        List<FunTVVideo2> video2List = funTVVideo2Dao.listByMediaId(id);
-        if (video2List != null) {
-            Comparator<FunTVVideo2> cm = new Comparator<FunTVVideo2>() {
-                @Override
-                public int compare(FunTVVideo2 o1, FunTVVideo2 o2) {
-                    return Integer.parseInt(o1.getNum()) - Integer.parseInt(o2.getNum());
-                }
-            };
-            Collections.sort(video2List, cm);
-        }
+        List<FunTVVideo2> video2List = listAllEpisodeList(id);
         album2.setEpisodes(video2List);
         return album2;
     }
 
+    private List<FunTVVideo2> getEpisodeList(String mediaId, int page, int pageSize) {
+        List<FunTVVideo2> video2List = funTVVideo2Dao.listByMediaId(mediaId, (page - 1) * pageSize, pageSize);
+        return video2List;
+    }
+
+    private List<FunTVVideo2> listAllEpisodeList(String mediaId) {
+        int page = 1;
+        int pageSize = 100;
+        List<FunTVVideo2> video2List = new ArrayList<>();
+        List<FunTVVideo2> tempList = new ArrayList<>();
+        do {
+            tempList = getEpisodeList(mediaId, page, pageSize);
+            if (tempList != null)
+                video2List.addAll(tempList);
+            page++;
+        } while (tempList != null && tempList.size() > 0);
+        return video2List;
+    }
+
+
     @Override
-    public List<VideoDetailInfo> getVideoDetailList(String id) {
+    public List<VideoDetailInfo> getVideoDetailList(String id, int page, int pageSize) {
         VideoFunTV2 videoFunTV2 = videoFunTV2Dao.selectByVideoId(id);
         if (videoFunTV2 == null)
             return null;
-        FunTVAlbum2 album2 = getAlbumDetail(videoFunTV2.getMediaId());
+        FunTVAlbum2 album2 = funTVAlbum2Dao.get(videoFunTV2.getMediaId());
+        if (album2 == null)
+            return null;
+
+        List<FunTVVideo2> episodeList = getEpisodeList(album2.getId(), page, pageSize);
+
         List<VideoDetailInfo> list = new ArrayList<>();
-        if (album2 != null && album2.getEpisodes() != null)
-            for (FunTVVideo2 video2 : album2.getEpisodes())
+        if (episodeList != null)
+            for (FunTVVideo2 video2 : episodeList)
                 list.add(FunTVUtil2.convertFunTVVideoToVideoDetail(video2, album2));
         return list;
     }
@@ -200,17 +217,17 @@
     }
 
     @Override
-    public PlayUrl getPlayUrl(String detailSystemId, int resourceId, String id, String videoId) {
+    public PlayUrl getPlayUrl(AcceptData acceptData, String detailSystemId, int resourceId, String id, String videoId) {
         FunTVVideo2 video2 = funTVVideo2Dao.get(id);
         VideoResource vr = videoResourceService.getResource(resourceId + "");
-        int t = FunTVUtil2.getPlayType(video2);
+        int t = FunTVUtil2.getPlayType(acceptData,video2);
         PlayUrl pu = new PlayUrl();
         pu.setParams("");
         pu.setPlayType(t);
         pu.setResource(vr);
         pu.setAid(video2.getMediaId());
         pu.setVid(video2.getId());
-
+        pu.setCode(video2.getCeCode());
         if (t == FunTVUtil2.PLAY_NONE) {
             pu.setUrl("");
         } else {
@@ -240,28 +257,11 @@
         VideoFunTV2 videoFunTV2 = videoFunTV2Dao.selectByMediaId(mediaId);
         if (videoFunTV2 == null)
             return;
-
-        List<ResourceVideo> resourceVideoList = resourceVideoService.getResourceList(videoFunTV2.getVideoId() + "");
-        for (int i = 0; i < resourceVideoList.size(); i++) {
-            ResourceVideo rv = resourceVideoList.get(i);
-            if (rv.getResource() != null && Integer.parseInt(rv.getResource().getId()) == FunTVUtil2.RESOURCE_ID) {
-                //鍒犻櫎璧勬簮鏄犲皠
-                resourceVideoService.delete(rv);
-                resourceVideoList.remove(i);
-                i--;
-            }
-        }
-
-        if (resourceVideoList.size() == 0) {
-            //闅愯棌瑙嗛
-            videoInfoService.hiddenVideo(videoFunTV2.getVideoId() + "");
-            //鏇存柊鎼滅储寮曟搸
-            CMQManager.getInstance().addSolrMsg(videoFunTV2.getVideoId() + "");
-        }
-
+        videoFunTV2Dao.deleteByVideoId(videoFunTV2.getVideoId());
+        resourceVideoService.delete(videoFunTV2.getVideoId()+"",FunTVUtil2.RESOURCE_ID+"");
         //鍒犻櫎濯掍綋涓庡獟浣撳搴旂殑瑙嗛
         funTVAlbum2Dao.delete(mediaId);
-        List<FunTVVideo2> video2List = funTVVideo2Dao.listByMediaId(mediaId);
+        List<FunTVVideo2> video2List = listAllEpisodeList(mediaId);
         if (video2List != null)
             for (FunTVVideo2 video2 : video2List)
                 funTVVideo2Dao.delete(video2.getId());

--
Gitblit v1.8.0