From 6b67f4c6b0165675df5e75815aeb0c1e01e9ef8a Mon Sep 17 00:00:00 2001 From: ronger Date: Tue, 31 Mar 2020 09:57:49 +0800 Subject: [PATCH] =?UTF-8?q?:speech=5Fballoon:=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=B3=A8=E9=87=8A=E5=92=8C=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=90=8D=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rymcu/vertical/mapper/CommentMapper.java | 9 +++- .../com/rymcu/vertical/mapper/TagMapper.java | 44 +++++++++++++++++++ .../service/impl/ArticleServiceImpl.java | 6 +-- .../service/impl/JavaMailServiceImpl.java | 3 +- ...{BaiduCronTask.java => BaiDuCronTask.java} | 7 ++- .../com/rymcu/vertical/util/BaiDuUtils.java | 27 ++---------- .../vertical/web/api/tag/TagController.java | 1 - 7 files changed, 65 insertions(+), 32 deletions(-) rename src/main/java/com/rymcu/vertical/task/{BaiduCronTask.java => BaiDuCronTask.java} (86%) diff --git a/src/main/java/com/rymcu/vertical/mapper/CommentMapper.java b/src/main/java/com/rymcu/vertical/mapper/CommentMapper.java index fba4a79..21dde41 100644 --- a/src/main/java/com/rymcu/vertical/mapper/CommentMapper.java +++ b/src/main/java/com/rymcu/vertical/mapper/CommentMapper.java @@ -8,28 +8,35 @@ import org.apache.ibatis.annotations.Param; import java.util.List; +/** + * @author ronger + */ public interface CommentMapper extends Mapper { /** + * 获取文章评论列表 * @param idArticle * @return */ List selectArticleComments(@Param("idArticle") Integer idArticle); /** + * 查询评论作者 * @param commentAuthorId * @return */ Author selectAuthor(@Param("commentAuthorId") Integer commentAuthorId); /** + * 查询父评论作者 * @param commentOriginalCommentId * @return */ Author selectCommentOriginalAuthor(@Param("commentOriginalCommentId") Integer commentOriginalCommentId); /** + * 更新文章评论分享链接 * @param idComment - * @param toString + * @param commentSharpUrl * @return */ Integer updateCommentSharpUrl(@Param("idComment") Integer idComment, @Param("commentSharpUrl") String commentSharpUrl); diff --git a/src/main/java/com/rymcu/vertical/mapper/TagMapper.java b/src/main/java/com/rymcu/vertical/mapper/TagMapper.java index ed4fbe2..f2643a6 100644 --- a/src/main/java/com/rymcu/vertical/mapper/TagMapper.java +++ b/src/main/java/com/rymcu/vertical/mapper/TagMapper.java @@ -7,20 +7,64 @@ import org.apache.ibatis.annotations.Param; import java.util.List; +/** + * @author ronger + */ public interface TagMapper extends Mapper { + + /** + * 插入标签文章表(vertical_tag_article)相关信息 + * @param idTag + * @param idArticle + * @return + */ Integer insertTagArticle(@Param("idTag") Integer idTag, @Param("idArticle") Integer idArticle); + /** + * 统计标签使用数(文章) + * @param idTag + * @param idArticle + * @return + */ Integer selectCountTagArticleById(@Param("idTag") Integer idTag, @Param("idArticle") Integer idArticle); + /** + * 获取用户标签数 + * @param idUser + * @param idTag + * @return + */ Integer selectCountUserTagById(@Param("idUser") Integer idUser, @Param("idTag") Integer idTag); + /** + * 插入用户标签信息 + * @param idTag + * @param idUser + * @param type + * @return + */ Integer insertUserTag(@Param("idTag") Integer idTag, @Param("idUser") Integer idUser, @Param("type") Integer type); + /** + * 删除未使用标签 + * @return + */ Integer deleteUnusedTag(); + /** + * 更新标签信息 + * @param idTag + * @param tagUri + * @param tagIconPath + * @param tagStatus + * @param tagDescription + * @param tagReservation + * @return + */ Integer update(@Param("idTag") Integer idTag, @Param("tagUri") String tagUri, @Param("tagIconPath") String tagIconPath, @Param("tagStatus") String tagStatus, @Param("tagDescription") String tagDescription, @Param("tagReservation") String tagReservation); /** + * 查询标签列表 * @return */ List selectTagLabels(); 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..2a077fc 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java @@ -100,7 +100,7 @@ public class ArticleServiceImpl extends AbstractService
implements Arti } @Override - @Transactional(rollbackFor = { UnsupportedEncodingException.class,BaseApiException.class }) + @Transactional(rollbackFor = { UnsupportedEncodingException.class, BaseApiException.class }) public Map postArticle(ArticleDTO article, HttpServletRequest request) throws UnsupportedEncodingException, BaseApiException { Map map = new HashMap(1); if(StringUtils.isBlank(article.getArticleTitle())){ @@ -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()); } } @@ -263,7 +263,7 @@ public class ArticleServiceImpl extends AbstractService
implements Arti return list; } - private ArticleDTO genArticle(ArticleDTO article,Integer type) { + private ArticleDTO genArticle(ArticleDTO article, Integer type) { Author author = articleMapper.selectAuthor(article.getArticleAuthorId()); article.setArticleAuthor(author); article.setTimeAgo(Utils.getTimeAgo(article.getUpdatedTime())); diff --git a/src/main/java/com/rymcu/vertical/service/impl/JavaMailServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/JavaMailServiceImpl.java index 7c3bc57..d5c0395 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/JavaMailServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/JavaMailServiceImpl.java @@ -48,7 +48,8 @@ public class JavaMailServiceImpl implements JavaMailService { private String USERNAME; @Value("${spring.mail.password}") private String PASSWORD; - private final static String BASE_URL = "https://rymcu.com"; + @Value("${resource.domain}") + private String BASE_URL; @Override public Integer sendEmailCode(String email) throws MessagingException { diff --git a/src/main/java/com/rymcu/vertical/task/BaiduCronTask.java b/src/main/java/com/rymcu/vertical/task/BaiDuCronTask.java similarity index 86% rename from src/main/java/com/rymcu/vertical/task/BaiduCronTask.java rename to src/main/java/com/rymcu/vertical/task/BaiDuCronTask.java index 9ef02a1..36b8f89 100644 --- a/src/main/java/com/rymcu/vertical/task/BaiduCronTask.java +++ b/src/main/java/com/rymcu/vertical/task/BaiDuCronTask.java @@ -7,9 +7,12 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +/** + * @author ronger + */ @Component @Slf4j -public class BaiduCronTask { +public class BaiDuCronTask { @Value("${resource.domain}") private String domain; @@ -22,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..262c558 100644 --- a/src/main/java/com/rymcu/vertical/util/BaiDuUtils.java +++ b/src/main/java/com/rymcu/vertical/util/BaiDuUtils.java @@ -11,8 +11,9 @@ import java.util.concurrent.*; */ public class BaiDuUtils { - private static String token = "9cdKR6bVCJzxDEJS"; - private static String site = "https://rymcu.com"; + private final static String token = "9cdKR6bVCJzxDEJS"; + + private final static String site = "https://rymcu.com"; public static void sendSEOData(String permalink) { if (StringUtils.isBlank(permalink) || StringUtils.isBlank(token)) { @@ -55,28 +56,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) { diff --git a/src/main/java/com/rymcu/vertical/web/api/tag/TagController.java b/src/main/java/com/rymcu/vertical/web/api/tag/TagController.java index 406645d..aa185a9 100644 --- a/src/main/java/com/rymcu/vertical/web/api/tag/TagController.java +++ b/src/main/java/com/rymcu/vertical/web/api/tag/TagController.java @@ -6,7 +6,6 @@ import com.rymcu.vertical.core.result.GlobalResult; import com.rymcu.vertical.core.result.GlobalResultGenerator; import com.rymcu.vertical.dto.ArticleDTO; import com.rymcu.vertical.dto.LabelModel; -import com.rymcu.vertical.entity.Tag; import com.rymcu.vertical.service.ArticleService; import com.rymcu.vertical.service.TagService; import com.rymcu.vertical.util.Utils;