wangyunpeng 11 mesi fa
parent
commit
ec1b749891

+ 3 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/Content.java

@@ -5,6 +5,8 @@ import lombok.Getter;
 import lombok.NoArgsConstructor;
 import lombok.Setter;
 
+import java.util.List;
+
 /**
  * @author dyp
  */
@@ -28,7 +30,7 @@ public class Content {
      */
     private String contentPoolType; // 内容池类别
     private String crawlerChannelContentId; // 抓取内容channelContentId
-    private String category; // 品类
+    private List<String> category; // 品类
     //    private String crawlerLink;
 //    private String crawlerTitle;
     private String crawlerCoverUrl;

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recall/ContentCategory.java

@@ -4,6 +4,6 @@ import lombok.Data;
 
 @Data
 public class ContentCategory {
-    private String channelContentId;
+    private String contentChannelId;
     private String category;
 }

+ 2 - 2
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recall/strategy/DefaultRecallStrategy.java

@@ -54,8 +54,8 @@ public class DefaultRecallStrategy implements RecallStrategy {
         if (CollectionUtils.isEmpty(categoryList)) {
             return;
         }
-        Map<String, String> categoryMap = categoryList.stream().collect(Collectors.toMap(ContentCategory::getChannelContentId,
-                ContentCategory::getCategory));
+        Map<String, List<String>> categoryMap = categoryList.stream().collect(Collectors.groupingBy(ContentCategory::getContentChannelId,
+                Collectors.mapping(ContentCategory::getCategory, Collectors.toList())));
         for (Content content : contentList) {
             content.setCategory(categoryMap.get(content.getCrawlerChannelContentId()));
         }