|
@@ -1,6 +1,7 @@
|
|
|
package cn.reghao.tnb.content.app.vod.service;
|
|
package cn.reghao.tnb.content.app.vod.service;
|
|
|
|
|
|
|
|
import cn.reghao.jutil.jdk.converter.DateTimeConverter;
|
|
import cn.reghao.jutil.jdk.converter.DateTimeConverter;
|
|
|
|
|
+import cn.reghao.jutil.jdk.db.PageList;
|
|
|
import cn.reghao.jutil.jdk.serializer.JsonConverter;
|
|
import cn.reghao.jutil.jdk.serializer.JsonConverter;
|
|
|
import cn.reghao.jutil.jdk.text.TextFile;
|
|
import cn.reghao.jutil.jdk.text.TextFile;
|
|
|
import cn.reghao.jutil.jdk.thread.ThreadPoolWrapper;
|
|
import cn.reghao.jutil.jdk.thread.ThreadPoolWrapper;
|
|
@@ -15,9 +16,12 @@ import cn.reghao.tnb.content.app.util.redis.ds.RedisSortedSet;
|
|
|
import cn.reghao.tnb.content.app.vod.model.vo.BannerVideoVO;
|
|
import cn.reghao.tnb.content.app.vod.model.vo.BannerVideoVO;
|
|
|
import cn.reghao.tnb.content.app.vod.service.rcmd.RedisKeys;
|
|
import cn.reghao.tnb.content.app.vod.service.rcmd.RedisKeys;
|
|
|
import cn.reghao.tnb.content.app.vod.service.rcmd.UserInterestBased;
|
|
import cn.reghao.tnb.content.app.vod.service.rcmd.UserInterestBased;
|
|
|
|
|
+import cn.reghao.tnb.search.api.dto.VideoSummary;
|
|
|
|
|
+import cn.reghao.tnb.search.api.iface.DataSearchService;
|
|
|
import com.google.gson.JsonElement;
|
|
import com.google.gson.JsonElement;
|
|
|
import com.google.gson.JsonObject;
|
|
import com.google.gson.JsonObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.junit.jupiter.api.Test;
|
|
import org.junit.jupiter.api.Test;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
@@ -402,4 +406,47 @@ public class VideoPostTest {
|
|
|
videoPostTagMapper.saveAll(list);
|
|
videoPostTagMapper.saveAll(list);
|
|
|
System.out.println(sb.toString());
|
|
System.out.println(sb.toString());
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @DubboReference(check = false, retries = 0, timeout = 60_000)
|
|
|
|
|
+ DataSearchService dataSearchService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ SearchService searchService;
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void putSearchDataTest() {
|
|
|
|
|
+ int pageSize = 1000;
|
|
|
|
|
+ int nextId = 0;
|
|
|
|
|
+ List<VideoPost> videoPosts = videoPostMapper.findAllById(pageSize, nextId);
|
|
|
|
|
+ while (!videoPosts.isEmpty()) {
|
|
|
|
|
+ List<VideoSummary> videoSummaryList = videoPosts.stream()
|
|
|
|
|
+ .map(this::getVideoSummary)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ if (!videoSummaryList.isEmpty()) {
|
|
|
|
|
+ dataSearchService.addVideoSummaryList(videoSummaryList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ nextId = videoPosts.get(videoPosts.size()-1).getId();
|
|
|
|
|
+ videoPosts = videoPostMapper.findAllById(pageSize, nextId);
|
|
|
|
|
+ log.info("start nextId {} with size {}", nextId, videoPosts.size());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private VideoSummary getVideoSummary(VideoPost videoPost) {
|
|
|
|
|
+ String videoId = videoPost.getVideoId();
|
|
|
|
|
+ String title = videoPost.getTitle();
|
|
|
|
|
+ int scope = videoPost.getScope();
|
|
|
|
|
+ long publishTime = DateTimeConverter.msTimestamp(videoPost.getPublishAt());
|
|
|
|
|
+ return new VideoSummary(videoId, title, scope, publishTime);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void searchVideoTest() {
|
|
|
|
|
+ int pn = 1;
|
|
|
|
|
+ String kw = "隔壁";
|
|
|
|
|
+ List<Integer> scopes = List.of(PostScope.PUBLIC.getCode(), PostScope.PROTECT.getCode());
|
|
|
|
|
+ PageList<VideoSummary> pageList = dataSearchService.searchVideo(kw, scopes, pn);
|
|
|
|
|
+ Map<String, List<VideoSummary>> map = pageList.getList().stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(VideoSummary::getVideoId));
|
|
|
|
|
+ PageList<VideoCard> pageList1 = searchService.searchByKeyword(kw, "", pn);
|
|
|
|
|
+ System.out.println();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|