Merge pull request #6 from rymcu/dev

🎨 代码结构及名称变更
This commit is contained in:
ronger 2020-03-31 08:58:45 +08:00 committed by GitHub
commit 707505c8f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 25 deletions

View File

@ -161,7 +161,7 @@ public class ArticleServiceImpl extends AbstractService<Article> 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());
}
}

View File

@ -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);
}
}

View File

@ -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<Runnable>());
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) {