From 431c684f254ba5163cb6256739215e2099b91aaf Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 31 三月 2021 19:17:09 +0800
Subject: [PATCH] 3.9.0兼容

---
 src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java |   54 ++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 42 insertions(+), 12 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 70b036a..7d5a3f8 100644
--- a/src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java
+++ b/src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java
@@ -35,6 +35,7 @@
 import com.yeshi.buwan.util.log.UserActiveLogFactory;
 import com.yeshi.buwan.util.log.VideoLogFactory;
 import com.yeshi.buwan.vo.AcceptData;
+import com.yeshi.buwan.vo.video.VideoDetailVO;
 import com.yeshi.buwan.youku.YouKuUtil;
 import com.yeshi.buwan.youku.entity.YouKuSearchVideoMap;
 import com.yeshi.buwan.youku.entity.YouKuShowDetail;
@@ -55,6 +56,9 @@
 
 @Controller
 public class HomeParser {
+
+    private Logger logger = LoggerFactory.getLogger(HomeParser.class);
+
     @Resource
     private SystemService systemService;
     @Resource
@@ -370,6 +374,8 @@
 
 
     public void getVideoDetailForInternetSearch(AcceptData acceptData, String videoId, HttpServletRequest request, PrintWriter out) {
+        String loginUid = request.getParameter("LoginUid");
+        String from = request.getParameter("From");
         InternetSearchVideo internetSearchVideo = internetSearchVideoService.selectByPrimaryKey(videoId);
         String resourceId = request.getParameter("ResourceId");
         if (StringUtil.isNullOrEmpty(resourceId)) {
@@ -379,7 +385,10 @@
         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;
             }
@@ -388,6 +397,7 @@
             try {
                 info = mogoTVUtil.getVideoInfo(internetSearchVideo);
             } catch (Exception e) {
+                logger.error("鍏ㄧ綉鎼滆棰戣鎯呭嚭閿欙細" + videoId);
                 out.print(JsonUtil.loadFalseAdmin(e.getMessage()));
                 return;
             }
@@ -395,17 +405,26 @@
             try {
                 info = tencentVideoUtil.getVideoInfo(internetSearchVideo);
             } catch (Exception e) {
+                logger.error("鍏ㄧ綉鎼滆棰戣鎯呭嚭閿欙細" + videoId);
                 out.print(JsonUtil.loadFalseAdmin(e.getMessage()));
                 return;
             }
         }
 
+        LoggerUtil.getUserActiveLogger().info(UserActiveLogFactory.createVideoDetail(new BaseLog(acceptData, loginUid), videoId, info.getName(), from));
+
         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()));
+
+        if (VersionUtil.isGraterThan390(acceptData.getPlatform(), acceptData.getVersion())) {
+            out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(new VideoDetailVO(Utils.convertVideo(info), new VideoDetailVO.VideoAdInfo(true,false), null)), array.toString(),
+                    obj.toString()));
+        } else {
+            out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(Utils.convertVideo(info)), array.toString(),
+                    obj.toString()));
+        }
     }
 
     @RequireUid
@@ -519,28 +538,39 @@
             info.setCommentCount((int) count);
 
         JSONObject obj = new JSONObject();
+        VideoDetailVO.AttentionInfo attention = null;
         if (info.getVideoDetailList() != null)
             if (info.getVideoDetailList().size() > 1) {// 澶氶泦,鍙叧娉�
                 boolean isAttention = false;
                 if (!StringUtil.isNullOrEmpty(loginUid)) {
                     isAttention = attentionService.isAddAttention(loginUid, info.getId());
                 }
+                attention = new VideoDetailVO.AttentionInfo();
+                attention.setName(info.getName());
+                attention.setPicture(info.getPicture());
+                if (StringUtil.isNullOrEmpty(info.getUpdatetime())) {
+                    attention.setUpdateInfo("鏇存柊:" + TimeUtil.getCommentTime(info.getCreatetime()));
+                } else {
+                    attention.setUpdateInfo("鏇存柊:" + TimeUtil.getCommentTime(Long.parseLong(info.getUpdatetime())));
+                }
+                attention.setAttention(isAttention);
+
+                //鍏煎鑰佺増鏈�
                 JSONObject attentionInfo = new JSONObject();
-                attentionInfo.put("Name", info.getName());
-                attentionInfo.put("Picture", info.getPicture());
-                if (StringUtil.isNullOrEmpty(info.getUpdatetime()))
-                    attentionInfo.put("UpdateInfo", "鏇存柊:" + TimeUtil.getCommentTime(info.getCreatetime()));
-                else
-                    attentionInfo.put("UpdateInfo", "鏇存柊:" + TimeUtil.getCommentTime(Long.parseLong(info.getUpdatetime())));
-                attentionInfo.put("IsAttention", isAttention);
+                attentionInfo.put("Picture", attention.getPicture());
+                attentionInfo.put("Name", attention.getName());
+                attentionInfo.put("UpdateInfo", attention.getUpdateInfo());
+                attentionInfo.put("IsAttention", attention.isAttention());
                 obj.put("Attention", attentionInfo);
             }
         UserInfo user = userService.getUserInfo(acceptData.getUid());
-        if (Utils.isTest(request, user, detailSystem.getId()))
-            out.print(JsonUtil.loadTrueJson(""));
-        else
+        if (VersionUtil.isGraterThan390(acceptData.getPlatform(), acceptData.getVersion())) {
+            out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(new VideoDetailVO(Utils.convertVideo(info), new VideoDetailVO.VideoAdInfo(true,true), attention)), array.toString(),
+                    obj.toString()));
+        } else {
             out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(Utils.convertVideo(info)), array.toString(),
                     obj.toString()));
+        }
     }
 
 

--
Gitblit v1.8.0