Browse Source

内部账号发布位置历史均值

wangyunpeng 11 months ago
parent
commit
038447a978

+ 10 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/crawler/AccountAvgInfoRepository.java

@@ -0,0 +1,10 @@
+package com.tzld.longarticle.recommend.server.repository.crawler;
+
+import com.tzld.longarticle.recommend.server.repository.entity.crawler.AccountAvgInfo;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface AccountAvgInfoRepository extends JpaRepository<AccountAvgInfo, AccountAvgInfo.PK> {
+
+}

+ 45 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/entity/crawler/AccountAvgInfo.java

@@ -0,0 +1,45 @@
+package com.tzld.longarticle.recommend.server.repository.entity.crawler;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Entity
+@Table(name = "account_avg_info")
+@IdClass(AccountAvgInfo.PK.class)
+public class AccountAvgInfo implements Serializable {
+
+    @Id
+    @Column(name = "gh_id")
+    private String ghId;
+    @Id
+    @Column(name = "position")
+    private String position;
+    @Column(name = "account_name")
+    private String accountName;
+    @Column(name = "fans")
+    private long fans;
+    @Column(name = "read_avg")
+    private double readAvg;
+    @Column(name = "like_avg")
+    private double likeAvg;
+
+    @Data
+    public static class PK implements Serializable {
+
+        @Column(name = "gh_id")
+        private String ghId;
+        @Column(name = "position")
+        private String position;
+
+        public PK() {
+        }
+
+    }
+}

+ 17 - 0
long-article-recommend-service/src/test/java/com/tzld/longarticle/recommend/server/FilterStrategyTest.java

@@ -1,10 +1,13 @@
 package com.tzld.longarticle.recommend.server;
 
+import cn.hutool.core.io.resource.ResourceUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.tencentcloudapi.tms.v20201229.models.TextModerationResponse;
 import com.tzld.longarticle.recommend.server.model.Content;
 import com.tzld.longarticle.recommend.server.remote.AIGCRemoteService;
 import com.tzld.longarticle.recommend.server.remote.ArticleSensitiveRemoteService;
+import com.tzld.longarticle.recommend.server.repository.crawler.AccountAvgInfoRepository;
+import com.tzld.longarticle.recommend.server.repository.entity.crawler.AccountAvgInfo;
 import com.tzld.longarticle.recommend.server.service.filter.FilterParam;
 import com.tzld.longarticle.recommend.server.service.filter.FilterResult;
 import com.tzld.longarticle.recommend.server.service.filter.FilterStrategy;
@@ -20,6 +23,7 @@ import java.io.File;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.util.List;
+import java.util.Set;
 
 @SpringBootTest(classes = Application.class)
 @Slf4j
@@ -33,6 +37,8 @@ public class FilterStrategyTest {
     AIGCRemoteService aigcRemoteService;
     @Resource
     ArticleSensitiveRemoteService articleSensitiveRemoteService;
+    @Resource
+    private AccountAvgInfoRepository accountAvgInfoRepository;
 //    @Test
 //    public void badStrategyTest() {
 //        FilterParam param = new FilterParam();
@@ -92,4 +98,15 @@ public class FilterStrategyTest {
             log.error("No JSON files found in the folder.");
         }
     }
+
+    @Test
+    void AccountAvgInfoTest() {
+        String cardJSON = ResourceUtil.readUtf8Str("file/AccountInfo.json");
+        JSONObject accountInfo = JSONObject.parseObject(cardJSON);
+        Set<String> keys = accountInfo.keySet();
+        for (String key : keys) {
+            AccountAvgInfo info = accountInfo.getObject(key, AccountAvgInfo.class);
+            accountAvgInfoRepository.save(info);
+        }
+    }
 }