Procházet zdrojové kódy

Merge branch 'wyp/1224-deleteByVideoId' of Server/long-article-recommend into master

wangyunpeng před 6 měsíci
rodič
revize
faa9688931

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/GetOffVideoArticleRepository.java

@@ -12,4 +12,6 @@ public interface GetOffVideoArticleRepository extends JpaRepository<GetOffVideoA
     List<GetOffVideoArticle> getByPublishTimeBetween(Long startTime, Long endTime);
 
     List<GetOffVideoArticle> getByPublishTimeGreaterThanEqual(Long publishTime);
+
+    GetOffVideoArticle getByVideoId(Long videoId);
 }

+ 26 - 12
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/ArticleAuditService.java

@@ -107,11 +107,13 @@ public class ArticleAuditService {
                 List<LongArticlesMatchVideoResponse> responseList = JSONArray.parseArray(longArticlesMatchVideo.getResponse()
                         , LongArticlesMatchVideoResponse.class);
                 for (LongArticlesMatchVideoResponse response : responseList) {
-                    String ossPath = getOssPath(response.getVideoPath());
-                    if (existsOssPath.contains(ossPath)) {
-                        continue;
+                    String ossPath = response.getVideoOSS();
+                    if (StringUtils.hasText(ossPath)) {
+                        if (existsOssPath.contains(ossPath)) {
+                            continue;
+                        }
+                        existsOssPath.add(ossPath);
                     }
-                    existsOssPath.add(ossPath);
                     LongArticleVideoAudit videoAudit = new LongArticleVideoAudit();
                     videoAudit.setVideoId(response.getVideoID());
                     videoAudit.setTraceId(traceId);
@@ -209,10 +211,21 @@ public class ArticleAuditService {
         }
     }
 
-    public void saveDeleteRecord(String ossPath) {
-        List<LongArticleCrawlerVideo> crawlerVideoList = longArticleCrawlerVideoRepository.getByVideoOssPath(ossPath);
+    public String saveDeleteRecord(Long videoId) {
+        GetOffVideoArticle getOffVideos = getOffVideoArticleRepository.getByVideoId(videoId);
+        String traceId = getOffVideos.getTraceId();
+        LongArticlesMatchVideo matchVideo = longArticlesMatchVideoRepository.getByTraceId(traceId);
+        List<LongArticlesMatchVideoResponse> responseList = JSONArray.parseArray(matchVideo.getResponse()
+                , LongArticlesMatchVideoResponse.class);
+        LongArticlesMatchVideoResponse response = responseList.stream()
+                .filter(o -> o.getVideoID() == videoId).findFirst().orElse(null);
+        if (Objects.isNull(response) || !StringUtils.hasText(response.getVideoOSS())) {
+            return "matchVideo response videoOss null videoId:" + videoId + " traceId:" + traceId;
+        }
+        List<LongArticleCrawlerVideo> crawlerVideoList = longArticleCrawlerVideoRepository.getByVideoOssPath(response.getVideoOSS());
         if (CollectionUtils.isEmpty(crawlerVideoList)) {
-            return;
+            return "matchVideo response videoOss findCrawlerVideo Null videoId:" + videoId +
+                    " traceId:" + traceId + " videoOss:" + response.getVideoOSS();
         }
         for (LongArticleCrawlerVideo longArticleCrawlerVideo : crawlerVideoList) {
             longArticleCrawlerVideo.setIsIllegal(1);
@@ -221,13 +234,13 @@ public class ArticleAuditService {
         List<String> contentIds = crawlerVideoList.stream().map(LongArticleCrawlerVideo::getContentId).collect(Collectors.toList());
         List<LongArticlesMatchVideo> matchVideoList = longArticlesMatchVideoRepository.getByContentIdIn(contentIds);
         Map<String, LongArticlesMatchVideo> matchVideoMap = matchVideoList.stream()
-               .collect(Collectors.toMap(LongArticlesMatchVideo::getTraceId, Function.identity()));
+                .collect(Collectors.toMap(LongArticlesMatchVideo::getTraceId, Function.identity()));
         List<String> traceIds = matchVideoList.stream().map(LongArticlesMatchVideo::getTraceId).collect(Collectors.toList());
         List<PublishContentMiniprogramDTO> publishContentMiniprogramList = aigcBaseMapper.getPublishContentByTraceIdIn(traceIds);
         List<String> publishContentIds = publishContentMiniprogramList.stream()
                 .map(PublishContentMiniprogramDTO::getPublishContentId).collect(Collectors.toList());
         Map<String, String> PublishTraceIdMap = publishContentMiniprogramList.stream()
-               .collect(Collectors.toMap(PublishContentMiniprogramDTO::getPublishContentId, PublishContentMiniprogramDTO::getTraceId));
+                .collect(Collectors.toMap(PublishContentMiniprogramDTO::getPublishContentId, PublishContentMiniprogramDTO::getTraceId));
         // 过滤状态非已发布内容
         List<PublishContent> publishContentList = publishContentRepository.getByIdIn(publishContentIds);
         List<String> publishedIds = publishContentList.stream()
@@ -237,9 +250,10 @@ public class ArticleAuditService {
         List<String> deleteTraceIds = publishContentIds.stream().map(PublishTraceIdMap::get).collect(Collectors.toList());
         // 重新匹配小程序
         List<String> reMatchTraceIds = traceIds.stream().filter(o -> !deleteTraceIds.contains(o)).collect(Collectors.toList());
-        buildReMatchRecord(reMatchTraceIds, ossPath, matchVideoMap);
+        buildReMatchRecord(reMatchTraceIds, response.getVideoOSS(), matchVideoMap);
         // 文章删除
         buildArticleAuditDelete(publishContentIds);
+        return null;
     }
 
     private void buildReMatchRecord(List<String> reMatchTraceIds, String ossPath,
@@ -430,8 +444,8 @@ public class ArticleAuditService {
         }
         // 处理视频内容池内容
         List<PublishContentDTO> videoPoolContents = publishContents.stream()
-               .filter(o -> Objects.equals(o.getSourceType(), PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal()))
-               .collect(Collectors.toList());
+                .filter(o -> Objects.equals(o.getSourceType(), PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal()))
+                .collect(Collectors.toList());
         if (CollectionUtils.isNotEmpty(videoPoolContents)) {
             for (PublishContentDTO videoPoolContent : videoPoolContents) {
                 longArticleBaseMapper.updateVideoPoolContentBad(videoPoolContent.getSourceId());

+ 2 - 3
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/web/recommend/ArticleAuditController.java

@@ -28,9 +28,8 @@ public class ArticleAuditController {
     }
 
     @GetMapping("/saveDeleteRecord")
-    public CommonResponse<Void> saveDeleteRecord(String ossPath) {
-        service.saveDeleteRecord(ossPath);
-        return CommonResponse.success();
+    public CommonResponse<String> saveDeleteRecord(Long videoId) {
+        return CommonResponse.success(service.saveDeleteRecord(videoId));
     }
 
     @PostMapping("/titleDangerFindDelete")