|
@@ -17,10 +17,13 @@ import cn.reghao.tnb.content.app.vod.service.ContentPermission;
|
|
|
import cn.reghao.tnb.content.app.vod.service.SearchService;
|
|
import cn.reghao.tnb.content.app.vod.service.SearchService;
|
|
|
import cn.reghao.tnb.content.app.vod.service.VideoPostQuery;
|
|
import cn.reghao.tnb.content.app.vod.service.VideoPostQuery;
|
|
|
import cn.reghao.tnb.content.app.util.redis.ds.RedisString;
|
|
import cn.reghao.tnb.content.app.util.redis.ds.RedisString;
|
|
|
|
|
+import cn.reghao.tnb.user.api.iface.UserService;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -31,6 +34,8 @@ import java.util.stream.Collectors;
|
|
|
public class SearchServiceImpl implements SearchService {
|
|
public class SearchServiceImpl implements SearchService {
|
|
|
@DubboReference(check = false, retries = 1, timeout = 60_000)
|
|
@DubboReference(check = false, retries = 1, timeout = 60_000)
|
|
|
private DataSearchService dataSearchService;
|
|
private DataSearchService dataSearchService;
|
|
|
|
|
+ @DubboReference(check = false, retries = 1, timeout = 60_000)
|
|
|
|
|
+ private UserService userService;
|
|
|
|
|
|
|
|
private final int pageSize = 12;
|
|
private final int pageSize = 12;
|
|
|
private final VideoPostMapper videoPostMapper;
|
|
private final VideoPostMapper videoPostMapper;
|
|
@@ -87,6 +92,27 @@ public class SearchServiceImpl implements SearchService {
|
|
|
return PageList.pageList(pageNumber, pageSize, total, list1);
|
|
return PageList.pageList(pageNumber, pageSize, total, list1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public PageList<VideoCard> searchByKeyword1(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);
|
|
|
|
|
+ List<VideoSummary> list2 = map.get(videoCard.getVideoId());
|
|
|
|
|
+ if (!list2.isEmpty()) {
|
|
|
|
|
+ videoCard.setTitle(list2.get(0).getTitle());
|
|
|
|
|
+ }
|
|
|
|
|
+ return videoCard;
|
|
|
|
|
+ })
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ return PageList.pageList(pageNumber, pageSize, (int) pageList.getTotalSize(), list1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private int getTotal(String keyword) {
|
|
private int getTotal(String keyword) {
|
|
|
String key = String.format("tnb:search:total:%s", keyword);
|
|
String key = String.format("tnb:search:total:%s", keyword);
|
|
|
String value = redisString.get(key);
|
|
String value = redisString.get(key);
|