Ver código fonte

HistoryArticle JPA

wangyunpeng 11 meses atrás
pai
commit
2b6dfeeb95

+ 0 - 15
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/remote/Article.java

@@ -1,15 +0,0 @@
-package com.tzld.longarticle.recommend.server.model.remote;
-
-import lombok.Data;
-
-@Data
-public class Article {
-
-    private String title;
-    private Integer itemIndex;
-    private Integer showViewCount;
-    private String contentURL;
-    private String msgTime;
-
-}
-

+ 4 - 4
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/remote/ArticleListRemoteService.java

@@ -3,8 +3,8 @@ package com.tzld.longarticle.recommend.server.remote;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.tzld.longarticle.recommend.server.common.HttpPoolFactory;
-import com.tzld.longarticle.recommend.server.model.remote.Article;
-import com.tzld.longarticle.recommend.server.repository.mapper.crawler.CrawlerBaseMapper;
+import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
+import com.tzld.longarticle.recommend.server.repository.entity.crawler.Article;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.http.HttpEntity;
@@ -28,7 +28,7 @@ import java.util.Objects;
 public class ArticleListRemoteService {
 
     @Autowired
-    CrawlerBaseMapper crawlerBaseMapper;
+    ArticleRepository articleRepository;
 
     private final CloseableHttpClient client = HttpPoolFactory.aigcPool();
     private static final String articleListUrl = "http://61.48.133.26:8179/artlce_list";
@@ -92,7 +92,7 @@ public class ArticleListRemoteService {
 
 
     private List<Article> getArticleListByDB(String accountName, List<Integer> indexList) {
-        return crawlerBaseMapper.getOfficialArticlesTitle(accountName, indexList);
+        return articleRepository.getByAccountNameAndItemIndexInAndTypeEquals(accountName, indexList, "9");
     }
 
 }

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

@@ -0,0 +1,14 @@
+package com.tzld.longarticle.recommend.server.repository.crawler;
+
+import com.tzld.longarticle.recommend.server.repository.entity.crawler.Article;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface ArticleRepository extends JpaRepository<Article, String> {
+
+    List<Article> getByAccountNameAndItemIndexInAndTypeEquals(String accountName, List<Integer> indexList, String type);
+
+}

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

@@ -0,0 +1,70 @@
+package com.tzld.longarticle.recommend.server.repository.entity.crawler;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Entity
+@Table(name = "official_articles")
+public class Article implements Serializable {
+
+    @Column(name = "ghId")
+    private String ghId;
+    @Column(name = "accountName")
+    private String accountName;
+    @Column(name = "appMsgId")
+    private String appMsgId;
+    @Column(name = "title")
+    private String title;
+    @Column(name = "Type")
+    private String type;
+    @Column(name = "createTime")
+    private Long createTime;
+    @Column(name = "updateTime")
+    private Long updateTime;
+    @Column(name = "Digest")
+    private String digest;
+    @Column(name = "ItemIndex")
+    private Integer itemIndex;
+    @Column(name = "ContentUrl")
+    private String contentUrl;
+    @Column(name = "SourceUrl")
+    private String sourceUrl;
+    @Column(name = "CoverImgUrl")
+    private String coverImgUrl;
+    @Column(name = "CoverImgUrl_1_1")
+    private String coverImgUrl_1_1;
+    @Column(name = "CoverImgUrl_255_1")
+    private String coverImgUrl_255_1;
+    @Column(name = "ItemShowType")
+    private String itemShowType;
+    @Column(name = "IsOriginal")
+    private String isOriginal;
+    @Column(name = "ShowDesc")
+    private String showDesc;
+    @Column(name = "ori_content")
+    private String oriContent;
+    @Column(name = "show_view_count")
+    private Integer showViewCount;
+    @Column(name = "show_like_count")
+    private Integer showLikeCount;
+    @Column(name = "show_zs_count")
+    private Integer showZsCount;
+    @Column(name = "show_pay_count")
+    private Integer showPayCount;
+    @Id
+    @Column(name = "wx_sn")
+    private String wxSn;
+    @Column(name = "baseInfo")
+    private String baseInfo;
+}
+

+ 0 - 3
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/mapper/crawler/CrawlerBaseMapper.java

@@ -1,6 +1,5 @@
 package com.tzld.longarticle.recommend.server.repository.mapper.crawler;
 
-import com.tzld.longarticle.recommend.server.model.remote.Article;
 import com.tzld.longarticle.recommend.server.service.recall.ContentCategory;
 import org.apache.ibatis.annotations.Param;
 
@@ -8,7 +7,5 @@ import java.util.List;
 
 public interface CrawlerBaseMapper {
 
-    List<Article> getOfficialArticlesTitle(@Param("accountName") String accountName, @Param("indexList") List<Integer> indexList);
-
     List<ContentCategory> getContentCategory(@Param("channelContentIds") List<String> channelContentIds);
 }

+ 0 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/strategy/BadStrategy.java

@@ -21,7 +21,6 @@ public class BadStrategy implements FilterStrategy {
     @Autowired
     private AIGCRemoteService aigcRemoteService;
 
-
     @ApolloJsonValue("${badTitles:[]}")
     private static List<String> badTitles;
 

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/strategy/HistoryTitleStrategy.java

@@ -1,7 +1,7 @@
 package com.tzld.longarticle.recommend.server.service.filter.strategy;
 
 import com.tzld.longarticle.recommend.server.model.Content;
-import com.tzld.longarticle.recommend.server.model.remote.Article;
+import com.tzld.longarticle.recommend.server.repository.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.remote.ArticleListRemoteService;
 import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.filter.FilterParam;

+ 6 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/strategy/SensitiveStrategy.java

@@ -1,5 +1,6 @@
 package com.tzld.longarticle.recommend.server.service.filter.strategy;
 
+import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
 import com.tzld.longarticle.recommend.server.model.Content;
 import com.tzld.longarticle.recommend.server.remote.ArticleSensitiveRemoteService;
@@ -25,6 +26,9 @@ public class SensitiveStrategy implements FilterStrategy {
     @Autowired
     private ArticleSensitiveRemoteService articleSensitiveRemoteService;
 
+    @ApolloJsonValue("${UnSafeTitles:[]}")
+    private static List<String> UnSafeTitles;
+
     private final ExecutorService pool = ThreadPoolFactory.defaultPool();
 
     @Override
@@ -42,6 +46,8 @@ public class SensitiveStrategy implements FilterStrategy {
                     boolean isSensitive = articleSensitiveRemoteService.articleSensitive(content.getTitle());
                     if (isSensitive) {
                         content.setFilterReason("安全违规");
+                    } else if (UnSafeTitles.contains(content.getTitle())) {
+                        content.setFilterReason("安全违规");
                     }
                     return content;
                 } finally {

+ 0 - 10
long-article-recommend-service/src/main/resources/mapper/crawler/CrawlerBaseMapper.xml

@@ -2,16 +2,6 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.tzld.longarticle.recommend.server.repository.mapper.crawler.CrawlerBaseMapper">
 
-    <select id="getOfficialArticlesTitle" resultType="com.tzld.longarticle.recommend.server.model.remote.Article">
-        select title
-        from official_articles
-        where accountName = #{accountName}
-        and itemIndex in
-        <foreach collection="indexList" item="item" separator="," open="(" close=")">
-            #{item}
-        </foreach>
-        and type = 9
-    </select>
 
     <select id="getContentCategory"
             resultType="com.tzld.longarticle.recommend.server.service.recall.ContentCategory">