From f3ff5ab043cf612e119fd90cd82e49b2cfc2ab5a Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 27 四月 2021 19:19:53 +0800
Subject: [PATCH] 搜索引擎优化,Bilibili初步集成

---
 src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java |   41 ++++++++++++++++++++++++++++++++++-------
 1 files changed, 34 insertions(+), 7 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 4d60e6c..efa472e 100644
--- a/src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java
+++ b/src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java
@@ -31,6 +31,7 @@
 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.recommend.HomeVideoService;
 import com.yeshi.buwan.service.inter.video.VideoWatchHistoryService;
 import com.yeshi.buwan.service.manager.VideoPlayStatisticManager;
 import com.yeshi.buwan.tencent.TencentVideoUtil;
@@ -71,6 +72,10 @@
     private HomeAdService homeAdService;
     @Resource
     private HomeTypeService homeTypeService;
+
+    @Resource
+    private HomeVideoService homeVideoService;
+
     @Resource
     private DetailSystemConfigService configService;
     @Resource
@@ -310,11 +315,11 @@
 
                 long bigPictureCount = homeType.isBigPicture() ? 1 : 0;// homeTypeService.getHomeVideoListCount(homeType.getId(), resourceKey, resourceList, true);
 
-                List<HomeVideo> homeVideoList = homeTypeService.getHomeVideoList(homeType.getId(), resourceKey, resourceList, null, 1, homeType.getNumber() + (int) bigPictureCount);
+                List<HomeVideo> homeVideoList = homeVideoService.getHomeVideoList(homeType.getId(), resourceKey, resourceList, null, 1, homeType.getNumber() + (int) bigPictureCount);
                 if (bigPictureCount > 0 && homeVideoList.size() > 0) {
                     homeVideoList.get(0).setBigPicture(true);
                 }
-                long videoCount = homeTypeService.getHomeVideoListCount(homeType.getId(), resourceKey, resourceList, null);
+                long videoCount = homeVideoService.getHomeVideoListCount(homeType.getId(), resourceKey, resourceList, null);
 
                 if (videoCount - bigPictureCount > homeType.getNumber()) {
                     while ((videoCount - bigPictureCount) % homeType.getNumber() != 0) {
@@ -329,6 +334,28 @@
 
                 homeType.setHomeVideoList(tempHomeVideoList);
             }
+
+        try {
+            if (VersionUtil.isGraterThan387(acceptData.getPlatform(), acceptData.getVersion()) && dataKey.equalsIgnoreCase("recommend")) {
+                DetailSystemConfig adContent = configService.getConfigByKey("home_banner_ad_content", acceptData.getDetailSystem(), acceptData.getVersion());
+                DetailSystemConfig adPosition = configService.getConfigByKey("home_banner_ad_position", acceptData.getDetailSystem(), acceptData.getVersion());
+                if (adContent != null && adPosition != null) {
+                    HomeType.HomeTypeAd ad = new Gson().fromJson(adContent.getValue(), HomeType.HomeTypeAd.class);
+                    int adP = Integer.parseInt(adPosition.getValue());
+                    if (adP < homeTypeList.size() && adP > -1) {
+                        HomeType homeType = new HomeType();
+                        homeType.setAd(ad);
+                        if ("1".equalsIgnoreCase(page)) {
+                            homeTypeList.add(adP, homeType);
+                        }
+                        count++;
+                    }
+                }
+            }
+        } catch (Exception e) {
+
+        }
+
 
         JSONObject object = new JSONObject();
         JSONArray array = new JSONArray();
@@ -375,7 +402,7 @@
         List<HomeVideo> bigPictureVideos = new ArrayList<>();
 
         if (homeType.isBigPicture()) {
-            bigPictureVideos = homeTypeService.getHomeVideoList(homeTypeId, org.yeshi.utils.StringUtil.concat(resourceList, ","), resourceList, null, 1, 1);
+            bigPictureVideos = homeVideoService.getHomeVideoList(homeTypeId, org.yeshi.utils.StringUtil.concat(resourceList, ","), resourceList, null, 1, 1);
             if (bigPictureVideos != null && bigPictureVideos.size() > 0)
                 bigPictureVideos.get(0).setBigPicture(true);
         }
@@ -385,7 +412,7 @@
         JSONObject object = new JSONObject();
         String resourceKey = StringUtil.Md5(org.yeshi.utils.StringUtil.concat(resourceList, ","));
 
-        Long count = homeTypeService.getHomeVideoListCount(homeTypeId, resourceKey, resourceList, null);
+        Long count = homeVideoService.getHomeVideoListCount(homeTypeId, resourceKey, resourceList, null);
         if (count - bigPictureVideos.size() > homeType.getNumber()) {
 
             while ((count - bigPictureVideos.size()) % homeType.getNumber() != 0) {
@@ -394,7 +421,7 @@
         }
 
 
-        List<HomeVideo> list1 = homeTypeService.getHomeVideoList(homeTypeId, resourceKey, resourceList, homeType.isBigPicture(), page, homeType.getNumber());
+        List<HomeVideo> list1 = homeVideoService.getHomeVideoList(homeTypeId, resourceKey, resourceList, homeType.isBigPicture(), page, homeType.getNumber());
         List<HomeVideo> list = new ArrayList<>();
         list.addAll(bigPictureVideos);
         list.addAll(list1);
@@ -441,7 +468,7 @@
 
         List<HomeVideo> homeVideoList = homeTypeService.getVideoByTypes(type, pageIndex, detailSystem);
 
-        List<VideoInfo> list = new ArrayList<VideoInfo>();
+        List<VideoInfo> list = new ArrayList<>();
         for (int i = 0; i < homeVideoList.size(); i++) {
             HomeVideo hv = (HomeVideo) homeVideoList.get(i);
             if (acceptData.getPackageName().contains("doudou")) {
@@ -773,7 +800,7 @@
         if (VersionUtil.isGraterThan390(acceptData.getPlatform(), acceptData.getVersion())) {
             String sessionId = createVideoDetailSessionId(acceptData, loginUid, info.getName(), videoId, resourceId);
 
-            out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(new VideoDetailVO(Utils.convertVideo(info), deviceAdStrategyService.getVideoDetailAdStrategy(acceptData.getUtdId(), acceptData.getDetailSystem().getId(), loginUid), attention, sessionId)), array.toString(),
+            out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(new VideoDetailVO(Utils.convertVideo(info), deviceAdStrategyService.getVideoDetailAdStrategy(acceptData.getUtdId(), acceptData.getDetailSystem().getId(), loginUid,videoId,from), attention, sessionId)), array.toString(),
                     obj.toString()));
         } else {
             out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(Utils.convertVideo(info)), array.toString(),

--
Gitblit v1.8.0