Преглед на файлове

account_category version

wangyunpeng преди 1 месец
родител
ревизия
b1bfa1ab1d

+ 3 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/entity/longArticle/AccountCategory.java

@@ -26,6 +26,9 @@ public class AccountCategory {
     @Column(name = "status")
     private Integer status;
 
+    @Column(name = "version")
+    private Integer version;
+
     @Column(name = "create_timestamp")
     private Long createTimestamp;
 

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

@@ -9,8 +9,8 @@ import java.util.List;
 @Repository
 public interface AccountCategoryRepository extends JpaRepository<AccountCategory, AccountCategory.PK> {
 
-    List<AccountCategory> getByGhIdAndStatus(String ghId, Integer status);
+    List<AccountCategory> getByGhIdAndStatusAndVersion(String ghId, Integer status, Integer version);
 
-    List<AccountCategory> getByStatus(Integer status);
+    List<AccountCategory> getByStatusAndVersion(Integer status, Integer version);
 
 }

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

@@ -486,7 +486,7 @@ public class RecallService implements ApplicationContextAware {
                 .filter(o -> "1".equals(o.getPosition()))
                 .filter(o -> Objects.nonNull(o.getReadAvg()) && o.getReadAvg() > 0 && o.getFans() > 1000)
                 .collect(Collectors.groupingBy(AccountAvgInfo::getGhId, Collectors.toMap(AccountAvgInfo::getUpdateTime, o -> o)));
-        List<AccountCategory> accountCategoryList = accountCategoryRepository.getByStatus(StatusEnum.ONE.getCode());
+        List<AccountCategory> accountCategoryList = accountCategoryRepository.getByStatusAndVersion(StatusEnum.ONE.getCode(), activeVersion);
         Map<String, JSONObject> accountCategoryMap = accountCategoryList.stream().filter(o -> StringUtils.hasText(o.getCategoryMap()))
                 .collect(Collectors.toMap(AccountCategory::getGhId, o -> JSONObject.parseObject(o.getCategoryMap())));
 

+ 5 - 2
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/score/strategy/CategoryStrategy.java

@@ -35,6 +35,9 @@ public class CategoryStrategy implements ScoreStrategy {
     @ApolloJsonValue("${accountCategoryWeightConfig:{}}")
     private Map<String, AccountCategoryWeightConfig[]> accountCategoryWeightConfigMap;
 
+    @Value("${category.active.version:1}")
+    private Integer activeVersion;
+
     @Override
     public List<Score> score(ScoreParam param) {
         long start = System.currentTimeMillis();
@@ -42,8 +45,8 @@ public class CategoryStrategy implements ScoreStrategy {
         if (CollectionUtils.isEmpty(param.getContents())) {
             return scores;
         }
-        List<AccountCategory> accountCategoryList = accountCategoryRepository.getByGhIdAndStatus(
-                param.getGhId(), StatusEnum.ONE.getCode());
+        List<AccountCategory> accountCategoryList = accountCategoryRepository.getByGhIdAndStatusAndVersion(
+                param.getGhId(), StatusEnum.ONE.getCode(), activeVersion);
         if (CollectionUtils.isEmpty(accountCategoryList)) {
             return scores;
         }