From 33395df3e6a9ce42973ba708342f9f0b088ec7a4 Mon Sep 17 00:00:00 2001 From: x ronger Date: Wed, 16 Sep 2020 22:56:21 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E6=96=87=E7=AB=A0=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E7=99=BE=E5=BA=A6=E6=90=9C=E7=B4=A2=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ArticleServiceImpl.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java index ccc9b6a..0aa5f2a 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java @@ -114,6 +114,7 @@ public class ArticleServiceImpl extends AbstractService
implements Arti map.put("message", "正文不能为空!"); return map; } + boolean isUpdate = false; String articleTitle = article.getArticleTitle(); String articleTags = article.getArticleTags(); String articleContent = article.getArticleContent(); @@ -141,10 +142,8 @@ public class ArticleServiceImpl extends AbstractService
implements Arti newArticle.setArticleStatus(article.getArticleStatus()); articleMapper.insertSelective(newArticle); articleMapper.insertArticleContent(newArticle.getIdArticle(), articleContent, articleContentHtml); - if (!ProjectConstant.ENV.equals(env) && defaultStatus.equals(newArticle.getArticleStatus()) && articleContent.length() >= MAX_PREVIEW) { - BaiDuUtils.sendSEOData(newArticle.getArticlePermalink()); - } } else { + isUpdate = true; newArticle = articleMapper.selectByPrimaryKey(article.getIdArticle()); if (!user.getIdUser().equals(newArticle.getArticleAuthorId())) { map.put("message", "非法访问!"); @@ -155,9 +154,6 @@ public class ArticleServiceImpl extends AbstractService
implements Arti newArticle.setArticleStatus(article.getArticleStatus()); newArticle.setUpdatedTime(new Date()); articleMapper.updateArticleContent(newArticle.getIdArticle(), articleContent, articleContentHtml); - if (!ProjectConstant.ENV.equals(env) && defaultStatus.equals(newArticle.getArticleStatus()) && articleContent.length() >= MAX_PREVIEW) { - BaiDuUtils.sendUpdateSEOData(newArticle.getArticlePermalink()); - } } if (notification && defaultStatus.equals(newArticle.getArticleStatus())) { @@ -184,6 +180,17 @@ public class ArticleServiceImpl extends AbstractService
implements Arti } articleMapper.updateByPrimaryKeySelective(newArticle); + // 推送百度 SEO + if (!ProjectConstant.ENV.equals(env) + && defaultStatus.equals(newArticle.getArticleStatus()) + && articleContent.length() >= MAX_PREVIEW) { + if (isUpdate) { + BaiDuUtils.sendUpdateSEOData(newArticle.getArticlePermalink()); + } else { + BaiDuUtils.sendSEOData(newArticle.getArticlePermalink()); + } + } + map.put("id", newArticle.getIdArticle()); return map; }