|
|
@@ -1,81 +0,0 @@
|
|
|
-package cn.reghao.tnb.content.app.vod.service;
|
|
|
-
|
|
|
-import cn.reghao.jutil.jdk.db.PageList;
|
|
|
-import cn.reghao.tnb.content.api.constant.PostScope;
|
|
|
-import cn.reghao.tnb.content.api.dto.VideoCard;
|
|
|
-import cn.reghao.tnb.content.app.ContentApplication;
|
|
|
-import cn.reghao.tnb.content.app.vod.db.mapper.VideoPostMapper;
|
|
|
-import cn.reghao.tnb.content.app.vod.model.po.VideoPost;
|
|
|
-import cn.reghao.tnb.search.api.dto.VideoSummary;
|
|
|
-import cn.reghao.tnb.search.api.iface.DataSearchService;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
-import org.junit.jupiter.api.Test;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.boot.test.context.SpringBootTest;
|
|
|
-import org.springframework.test.context.ActiveProfiles;
|
|
|
-import org.springframework.test.context.junit4.SpringRunner;
|
|
|
-
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-/**
|
|
|
- * @author reghao
|
|
|
- * @date 2025-04-02 16:10:18
|
|
|
- */
|
|
|
-@Slf4j
|
|
|
-@ActiveProfiles("dev")
|
|
|
-@SpringBootTest(classes = ContentApplication.class)
|
|
|
-public class SearchTest {
|
|
|
- @DubboReference(check = false)
|
|
|
- DataSearchService dataSearchService;
|
|
|
- @Autowired
|
|
|
- SearchService searchService;
|
|
|
- @Autowired
|
|
|
- VideoPostMapper videoPostMapper;
|
|
|
- @Test
|
|
|
- public void searchTest() {
|
|
|
- /*long userId = 10002L;
|
|
|
- String itemsKey = RedisKeys.getUserItemKey(userId);
|
|
|
- List<VideoCard> videoCards = new ArrayList<>();
|
|
|
- List<Object> list = redisSet.spop(itemsKey, 12);
|
|
|
- for (Object obj : list) {
|
|
|
- if (obj instanceof VideoCard) {
|
|
|
- videoCards.add((VideoCard) obj);
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
- 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());
|
|
|
- }
|
|
|
-
|
|
|
- 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();
|
|
|
- }
|
|
|
-
|
|
|
- private VideoSummary getVideoSummary(VideoPost videoPost) {
|
|
|
- String videoId = videoPost.getVideoId();
|
|
|
- String title = videoPost.getTitle();
|
|
|
- int scope = videoPost.getScope();
|
|
|
- return new VideoSummary(videoId, title, scope);
|
|
|
- }
|
|
|
-}
|