From d2be9e3afc38cc959b5a692767caf6ec861cc45d Mon Sep 17 00:00:00 2001 From: suwen <577014284@qq.com> Date: Fri, 26 Feb 2021 10:49:44 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E8=8D=89=E7=A8=BF=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E4=B8=8D=E6=9B=B4=E6=96=B0=E7=B4=A2=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新删除自动更新索引 --- .../rymcu/forest/service/impl/ArticleServiceImpl.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java index faaa500..e12cd93 100644 --- a/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java @@ -8,6 +8,7 @@ import com.rymcu.forest.entity.Article; import com.rymcu.forest.entity.ArticleContent; import com.rymcu.forest.entity.Tag; import com.rymcu.forest.entity.User; +import com.rymcu.forest.lucene.service.LuceneService; import com.rymcu.forest.mapper.ArticleMapper; import com.rymcu.forest.service.ArticleService; import com.rymcu.forest.service.CommentService; @@ -41,6 +42,8 @@ public class ArticleServiceImpl extends AbstractService
implements Arti private UserService userService; @Resource private CommentService commentService; + @Resource + private LuceneService luceneService; @Value("${resource.domain}") private String domain; @@ -176,6 +179,13 @@ public class ArticleServiceImpl extends AbstractService
implements Arti } } + System.out.println("开始增加索引"); + if (isUpdate) { + luceneService.writeArticle(newArticle.getIdArticle().toString()); + } else { + luceneService.updateArticle(newArticle.getIdArticle().toString()); + } + tagService.saveTagArticle(newArticle, articleContentHtml); if (defaultStatus.equals(newArticle.getArticleStatus())) { @@ -256,6 +266,7 @@ public class ArticleServiceImpl extends AbstractService
implements Arti deleteLinkedData(id); // 删除文章 result = articleMapper.deleteByPrimaryKey(id); + luceneService.deleteArticle(id.toString()); if (result < 1) { map.put("message", "删除失败!"); }