From 71613f2db369a8cd5dfd9eed51e099955bd12cf1 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 27 三月 2021 16:53:47 +0800
Subject: [PATCH] 全网搜bug修复

---
 src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java |   81 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 81 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java b/src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java
index dbe8e6b..4888919 100644
--- a/src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java
+++ b/src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java
@@ -15,20 +15,29 @@
 import com.yeshi.buwan.domain.recommend.HomeRecommendSpecial;
 import com.yeshi.buwan.domain.system.DetailSystemConfig;
 import com.yeshi.buwan.domain.system.DetailSystem;
+import com.yeshi.buwan.domain.video.InternetSearchVideo;
 import com.yeshi.buwan.domain.video.VideoWatchHistory;
 import com.yeshi.buwan.dto.log.BaseLog;
+import com.yeshi.buwan.mogotv.MogoTVUtil;
 import com.yeshi.buwan.pptv.PPTVUtil;
 import com.yeshi.buwan.pptv.entity.PPTVSeries;
 import com.yeshi.buwan.service.imp.*;
+import com.yeshi.buwan.service.inter.juhe.InternetSearchVideoService;
 import com.yeshi.buwan.service.inter.juhe.PPTVService;
+import com.yeshi.buwan.service.inter.juhe.YouKuService;
 import com.yeshi.buwan.service.inter.recommend.HomeRecommendSpecialService;
 import com.yeshi.buwan.service.inter.video.VideoWatchHistoryService;
+import com.yeshi.buwan.tencent.TencentVideoUtil;
 import com.yeshi.buwan.util.*;
 import com.yeshi.buwan.util.annotation.RequireUid;
+import com.yeshi.buwan.util.factory.VideoInfoFactory;
 import com.yeshi.buwan.util.log.LoggerUtil;
 import com.yeshi.buwan.util.log.UserActiveLogFactory;
 import com.yeshi.buwan.util.log.VideoLogFactory;
 import com.yeshi.buwan.vo.AcceptData;
+import com.yeshi.buwan.youku.YouKuUtil;
+import com.yeshi.buwan.youku.entity.YouKuSearchVideoMap;
+import com.yeshi.buwan.youku.entity.YouKuShowDetail;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.methods.GetMethod;
@@ -46,6 +55,9 @@
 
 @Controller
 public class HomeParser {
+
+    private Logger logger=LoggerFactory.getLogger(HomeParser.class);
+
     @Resource
     private SystemService systemService;
     @Resource
@@ -347,9 +359,71 @@
         out.print(JsonUtil.loadTrueJson(object.toString()));
     }
 
+
+    @Resource
+    private InternetSearchVideoService internetSearchVideoService;
+    @Resource
+    private YouKuUtil youKuUtil;
+
+    @Resource
+    private MogoTVUtil mogoTVUtil;
+
+    @Resource
+    private TencentVideoUtil tencentVideoUtil;
+
+
+    public void getVideoDetailForInternetSearch(AcceptData acceptData, String videoId, HttpServletRequest request, PrintWriter out) {
+        InternetSearchVideo internetSearchVideo = internetSearchVideoService.selectByPrimaryKey(videoId);
+        String resourceId = request.getParameter("ResourceId");
+        if (StringUtil.isNullOrEmpty(resourceId)) {
+            resourceId = internetSearchVideo.getResourceIds().split(",")[0];
+        }
+        VideoInfo info = null;
+        if (Integer.parseInt(resourceId) == YouKuUtil.RESOURCE_ID) {
+            try {
+                info = youKuUtil.getVideoInfo(internetSearchVideo);
+
+            } catch (Exception e) {
+                logger.error("鍏ㄧ綉鎼滆棰戣鎯呭嚭閿欙細"+videoId);
+                e.printStackTrace();
+                out.print(JsonUtil.loadFalseAdmin(e.getMessage()));
+                return;
+            }
+
+        } else if (Integer.parseInt(resourceId) == MogoTVUtil.RESOURCE_ID) {
+            try {
+                info = mogoTVUtil.getVideoInfo(internetSearchVideo);
+            } catch (Exception e) {
+                logger.error("鍏ㄧ綉鎼滆棰戣鎯呭嚭閿欙細"+videoId);
+                out.print(JsonUtil.loadFalseAdmin(e.getMessage()));
+                return;
+            }
+        } else if (Integer.parseInt(resourceId) == TencentVideoUtil.RESOURCE_ID) {
+            try {
+                info = tencentVideoUtil.getVideoInfo(internetSearchVideo);
+            } catch (Exception e) {
+                logger.error("鍏ㄧ綉鎼滆棰戣鎯呭嚭閿欙細"+videoId);
+                out.print(JsonUtil.loadFalseAdmin(e.getMessage()));
+                return;
+            }
+        }
+
+        info.setWatchCount("" + (int) (Math.random() * 1000));
+
+        JSONArray array = new JSONArray();
+        JSONObject obj = new JSONObject();
+        out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(Utils.convertVideo(info)), array.toString(),
+                obj.toString()));
+    }
+
     @RequireUid
     public void getVideoDetail(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
         String videoId = request.getParameter("VideoId");
+        if (!NumberUtil.isNumeric(videoId)) {
+            getVideoDetailForInternetSearch(acceptData, videoId, request, out);
+            return;
+        }
+
         String resourceId = request.getParameter("ResourceId");
         String thirdType = request.getParameter("Type");
         String loginUid = request.getParameter("LoginUid");
@@ -477,6 +551,7 @@
                     obj.toString()));
     }
 
+
     /**
      * 鑾峰彇瑙嗛鐨勫墽闆嗗垪琛�
      *
@@ -532,6 +607,12 @@
             return;
         }
 
+        if (!NumberUtil.isNumeric(detailId)) {
+            out.print(JsonUtil.loadFalseJson(""));
+            return;
+        }
+
+
         boolean collect = collectionService.isCollect(acceptData.getUid(), detailId, thirdType);
         if (collect)
             out.print(JsonUtil.loadTrueJson(""));

--
Gitblit v1.8.0