فهرست منبع

update SearchServiceImpl

reghao 11 ماه پیش
والد
کامیت
83d1b0d224

+ 14 - 5
content/content-service/src/main/java/cn/reghao/tnb/content/app/vod/service/impl/SearchServiceImpl.java

@@ -66,8 +66,18 @@ public class SearchServiceImpl implements SearchService {
     }
 
     public PageList<VideoCard> searchByKeyword(String keyword, String nextIdStr, int pageNumber) {
-        PageList<VideoSummary> pageList = dataSearchService.searchVideo(keyword, nextIdStr, pageNumber);
+        int type = 2;
+        PageList<VideoCard> pageList;
+        if (type == 1) {
+            pageList = searchByKeyword1(keyword, nextIdStr, pageNumber);
+        } else {
+            pageList = searchByKeyword2(keyword, nextIdStr, pageNumber);
+        }
+
+        return pageList;
+    }
 
+    public PageList<VideoCard> searchByKeyword1(String keyword, String nextIdStr, int pageNumber) {
         List<Integer> scopes = contentPermission.getUserScopes();
         SearchCriteria searchCriteria = new SearchCriteria.Builder().scope(scopes).title(keyword).build();
         /*int total = getTotal(keyword);
@@ -76,15 +86,14 @@ public class SearchServiceImpl implements SearchService {
             saveKeywordAsync(keyword);
             setTotal(keyword, total);
         }*/
-
         int total = videoPostMapper.countBySearchCriteria(searchCriteria);
         Page page = new Page(pageNumber, pageSize);
         List<VideoPost> list = videoPostMapper.findSearchCriteriaByPage(page, searchCriteria);
         if (list.isEmpty()) {
             return PageList.empty();
         }
-
         List<String> videoIds = list.stream().map(VideoPost::getVideoId).collect(Collectors.toList());
+
         List<VideoCard> list1 = videoPostMapper.findVideoCardByVideoIds(videoIds).stream()
                 .map(videoPostCard -> videoPostQuery.getVideoCard(videoPostCard, true))
                 .collect(Collectors.toList());
@@ -92,14 +101,14 @@ public class SearchServiceImpl implements SearchService {
         return PageList.pageList(pageNumber, pageSize, total, list1);
     }
 
-    public PageList<VideoCard> searchByKeyword1(String keyword, String nextIdStr, int pageNumber) {
+    public PageList<VideoCard> searchByKeyword2(String keyword, String nextIdStr, int pageNumber) {
         long loginUser = UserContext.getUser();
         boolean vip = userService.isVip(loginUser);
-
         PageList<VideoSummary> pageList = dataSearchService.searchVideo(keyword, vip+"", pageNumber);
         List<VideoSummary> videoSummaryList = pageList.getList();
         Map<String, List<VideoSummary>> map = videoSummaryList.stream().collect(Collectors.groupingBy(VideoSummary::getVideoId));
         List<String> videoIds = new ArrayList<>(map.keySet());
+
         List<VideoCard> list1 = videoPostMapper.findVideoCardByVideoIds(videoIds).stream()
                 .map(videoPostCard -> {
                     VideoCard videoCard = videoPostQuery.getVideoCard(videoPostCard, true);