Parcourir la source

ArticleSensitive jpa

wangyunpeng il y a 11 mois
Parent
commit
434bbf2bf7

+ 6 - 5
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/remote/ArticleSensitiveRemoteService.java

@@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 
 import java.util.Base64;
 import java.util.Objects;
@@ -35,8 +36,8 @@ public class ArticleSensitiveRemoteService {
         boolean isSensitive = false;
         String md5 = Md5Util.encoderByMd5(title);
         ArticleSensitive articleSensitive = getArticleSensitive(md5);
-        if (Objects.nonNull(articleSensitive)) {
-            if ("Pass".equals(articleSensitive.getSensitive())
+        if (Objects.nonNull(articleSensitive) && StringUtils.hasText(articleSensitive.getSensitiveSuggestion())) {
+            if ("Pass".equals(articleSensitive.getSensitiveSuggestion())
                     || ("Polity".equals(articleSensitive.getLabel()) && "ForeignLeader".equals(articleSensitive.getSubLabel()))) {
                 return false;
             } else {
@@ -77,12 +78,12 @@ public class ArticleSensitiveRemoteService {
     }
 
     public ArticleSensitive getArticleSensitive(String md5) {
-        return articleSensitiveRepository.getOne(md5);
+        return articleSensitiveRepository.findById(md5).orElse(null);
     }
 
-    public void insertArticleSensitive(String md5, String title, String sensitive, String label, String subLabel, String response) {
+    public void insertArticleSensitive(String md5, String title, String sensitiveSuggestion, String label, String subLabel, String response) {
         // 插入
-        ArticleSensitive insert = new ArticleSensitive(md5, title, sensitive, label, subLabel, response);
+        ArticleSensitive insert = new ArticleSensitive(md5, title, sensitiveSuggestion, label, subLabel, response);
         articleSensitiveRepository.save(insert);
     }
 

+ 2 - 2
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/entity/crawler/ArticleSensitive.java

@@ -20,8 +20,8 @@ public class ArticleSensitive implements Serializable {
     private String md5;
     @Column(name = "title")
     private String title;
-    @Column(name = "sensitive")
-    private String sensitive;
+    @Column(name = "sensitive_suggestion")
+    private String sensitiveSuggestion;
     @Column(name = "label")
     private String label;
     @Column(name = "sub_label")

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

@@ -1,7 +1,6 @@
 package com.tzld.longarticle.recommend.server.repository.mapper.crawler;
 
 import com.tzld.longarticle.recommend.server.model.remote.Article;
-import com.tzld.longarticle.recommend.server.repository.entity.crawler.ArticleSensitive;
 import com.tzld.longarticle.recommend.server.service.recall.ContentCategory;
 import org.apache.ibatis.annotations.Param;
 
@@ -9,15 +8,6 @@ import java.util.List;
 
 public interface CrawlerBaseMapper {
 
-    ArticleSensitive getArticleSensitiveByKey(@Param("md5") String md5);
-
-    int insertArticleSensitive(@Param("md5") String md5,
-                               @Param("title") String title,
-                               @Param("sensitive") String sensitive,
-                               @Param("label") String label,
-                               @Param("subLabel") String subLabel,
-                               @Param("response") String response);
-
     List<Article> getOfficialArticlesTitle(@Param("accountName") String accountName, @Param("indexList") List<Integer> indexList);
 
     List<ContentCategory> getContentCategory(@Param("channelContentIds") List<String> channelContentIds);

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

@@ -2,17 +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">
 
-    <insert id="insertArticleSensitive">
-        insert into article_sensitive(md5, title, `sensitive`, label, sub_label, response)
-        values (#{md5}, #{title}, #{sensitive}, #{label}, #{subLabel}, #{response})
-    </insert>
-
-
-    <select id="getArticleSensitiveByKey"
-            resultType="com.tzld.longarticle.recommend.server.repository.entity.crawler.ArticleSensitive">
-        select md5, title, `sensitive`, label, sub_label, response from article_sensitive where md5 = #{md5}
-    </select>
-
     <select id="getOfficialArticlesTitle" resultType="com.tzld.longarticle.recommend.server.model.remote.Article">
         select title
         from official_articles