From 375a1b9246e50c871c53f3cee0c9c6a4a91e07b2 Mon Sep 17 00:00:00 2001 From: ronger Date: Tue, 31 Mar 2020 08:56:48 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E5=8F=8A=E5=90=8D=E7=A7=B0=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ArticleServiceImpl.java | 2 +- ...{BaiduCronTask.java => BaiDuCronTask.java} | 4 ++-- .../com/rymcu/vertical/util/BaiDuUtils.java | 22 ------------------- 3 files changed, 3 insertions(+), 25 deletions(-) rename src/main/java/com/rymcu/vertical/task/{BaiduCronTask.java => BaiDuCronTask.java} (89%) 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 802c65a..a35cfdd 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java @@ -161,7 +161,7 @@ public class ArticleServiceImpl extends AbstractService
implements Arti newArticle.setUpdatedTime(new Date()); articleMapper.updateArticleContent(newArticle.getIdArticle(),articleContent,articleContentHtml); if (!ProjectConstant.ENV.equals(env) && defaultStatus.equals(newArticle.getArticleStatus())) { - BaiDuUtils.updateSEOData(newArticle.getArticlePermalink()); + BaiDuUtils.sendUpdateSEOData(newArticle.getArticlePermalink()); } } diff --git a/src/main/java/com/rymcu/vertical/task/BaiduCronTask.java b/src/main/java/com/rymcu/vertical/task/BaiDuCronTask.java similarity index 89% rename from src/main/java/com/rymcu/vertical/task/BaiduCronTask.java rename to src/main/java/com/rymcu/vertical/task/BaiDuCronTask.java index 1094982..36b8f89 100644 --- a/src/main/java/com/rymcu/vertical/task/BaiduCronTask.java +++ b/src/main/java/com/rymcu/vertical/task/BaiDuCronTask.java @@ -12,7 +12,7 @@ import org.springframework.stereotype.Component; */ @Component @Slf4j -public class BaiduCronTask { +public class BaiDuCronTask { @Value("${resource.domain}") private String domain; @@ -25,7 +25,7 @@ public class BaiduCronTask { @Scheduled(cron = "0 0 10,14,18 * * ?") public void pushHome() { if (!ProjectConstant.ENV.equals(env)) { - BaiDuUtils.updateSEOData(domain); + BaiDuUtils.sendUpdateSEOData(domain); } } diff --git a/src/main/java/com/rymcu/vertical/util/BaiDuUtils.java b/src/main/java/com/rymcu/vertical/util/BaiDuUtils.java index ec6ce89..9dd5239 100644 --- a/src/main/java/com/rymcu/vertical/util/BaiDuUtils.java +++ b/src/main/java/com/rymcu/vertical/util/BaiDuUtils.java @@ -55,28 +55,6 @@ public class BaiDuUtils { } return 0; },executor); - return; - } - - public static void updateSEOData(String permalink) { - if (StringUtils.isBlank(permalink) || StringUtils.isBlank(token)) { - return; - } - ExecutorService executor= new ThreadPoolExecutor(1,1,0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue()); - CompletableFuture.supplyAsync(()-> { - try { - HttpResponse response = HttpRequest.post("http://data.zz.baidu.com/update?site=" + site + "&token=" + token). - header("User-Agent", "curl/7.12.1"). - header("Host", "data.zz.baidu.com"). - header("Content-Type", "text/plain"). - header("Connection", "close").body(permalink.getBytes(), "text/plain").timeout(30000).send(); - response.charset("UTF-8"); - System.out.println(response.bodyText()); - } catch (Exception e){ - e.printStackTrace(); - } - return 0; - },executor); } public static void deleteSEOData(String permalink) {