|
@@ -0,0 +1,52 @@
|
|
|
+package com.tzld.longarticle.recommend.server;
|
|
|
+
|
|
|
+import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
|
|
|
+import com.tzld.longarticle.recommend.server.mapper.longArticle.LongArticleBaseMapper;
|
|
|
+import com.tzld.longarticle.recommend.server.model.dto.ProduceContentDTO;
|
|
|
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticlePoolPromotionSource;
|
|
|
+import com.tzld.longarticle.recommend.server.repository.longArticle.ArticlePoolPromotionSourceRepository;
|
|
|
+import com.tzld.longarticle.recommend.server.service.recommend.ArticleService;
|
|
|
+import com.tzld.longarticle.recommend.server.util.Md5Util;
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@SpringBootTest(classes = Application.class)
|
|
|
+public class XxlJobTest {
|
|
|
+ @Resource
|
|
|
+ private ArticleService articleService;
|
|
|
+ @Resource
|
|
|
+ private AigcBaseMapper aigcBaseMapper;
|
|
|
+ @Resource
|
|
|
+ private LongArticleBaseMapper longArticleBaseMapper;
|
|
|
+ @Resource
|
|
|
+ private ArticlePoolPromotionSourceRepository articlePoolPromotionSourceRepository;
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void test() {
|
|
|
+ List<String> planIds = Arrays.asList("20240804003153130851174", "20240802171417146947657", "20240802143345289374071");
|
|
|
+ List<String> levels = Arrays.asList("autoArticlePoolLevel3", "autoArticlePoolLevel1", "autoArticlePoolLevel1");
|
|
|
+ List<ArticlePoolPromotionSource> dis = articlePoolPromotionSourceRepository.findAll();
|
|
|
+ List<String> channelContentIds = dis.stream().map(ArticlePoolPromotionSource::getChannelContentId).collect(Collectors.toList());
|
|
|
+ for (int i = 0; i < planIds.size(); i++) {
|
|
|
+ List<ProduceContentDTO> list = aigcBaseMapper.getProduceContentByPlanId(planIds.get(i));
|
|
|
+ list = list.stream().filter(item -> !channelContentIds.contains(item.getContentId())).collect(Collectors.toList());
|
|
|
+ List<ArticlePoolPromotionSource> saveList = new ArrayList<>();
|
|
|
+ for (ProduceContentDTO produceContentDTO : list) {
|
|
|
+ ArticlePoolPromotionSource item = new ArticlePoolPromotionSource();
|
|
|
+ item.setChannelContentId(produceContentDTO.getContentId());
|
|
|
+ item.setTitle(produceContentDTO.getTitle());
|
|
|
+ item.setTitleMd5(Md5Util.encoderByMd5(produceContentDTO.getTitle()));
|
|
|
+ item.setLevel(levels.get(i));
|
|
|
+ item.setCreateTimestamp(System.currentTimeMillis());
|
|
|
+ saveList.add(item);
|
|
|
+ }
|
|
|
+ articlePoolPromotionSourceRepository.saveAll(saveList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|