洪城义警-正式版后台
tangzy
2022-01-05 62bce0f1102690a7254c7f805182d6f052d6480c
src/main/java/org/springblade/modules/article/controller/ArticleController.java
@@ -12,13 +12,14 @@
import org.springblade.modules.article.entity.Article;
import org.springblade.modules.article.service.ArticleService;
import org.springblade.modules.article.vo.ArticleVo;
import org.springblade.modules.words.DemoApplication;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
 * @author zhongrj
@@ -46,6 +47,22 @@
      response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
      response.setHeader("Access-Control-Allow-Credentials","true");
      return R.data(articleService.selectArticlePage(Condition.getPage(query),article));
   }
   /**
    *
    * 敏感词预警
    * @param response
    * @param article 资讯对象
    * @param query 查询参数
    * @return
    */
   @GetMapping("/pageWords")
   public R<IPage<Article>> pageWords(HttpServletResponse response, ArticleVo article, Query query){
      response.setHeader("Access-Control-Allow-Origin", "*");
      response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
      response.setHeader("Access-Control-Allow-Credentials","true");
      return R.data(articleService.pageWords(Condition.getPage(query),article));
   }
   /**
@@ -151,6 +168,20 @@
            article.setCreateTime(new Date());
         }
      }
      //默认为正常
      article.setIswords("0");
      if (article.getContent() != null && article.getContent() != ""){
         Map<String,String> content = new HashMap();
         content = DemoApplication.interceptWords(article.getContent());
         System.out.println(content.get("iswords"));
         if (content.get("iswords") == "true"){
            article.setContent(content.get("content"));
            article.setIswords("1");
            article.setWordsContent(content.get("words"));
         }
      }
      article.setUpdateTime(new Date());
      return R.status(articleService.saveOrUpdate(article));
   }