diff --git a/src/main/java/com/rymcu/vertical/core/constant/NotificationConstant.java b/src/main/java/com/rymcu/vertical/core/constant/NotificationConstant.java index 19bbb61..41e53a1 100644 --- a/src/main/java/com/rymcu/vertical/core/constant/NotificationConstant.java +++ b/src/main/java/com/rymcu/vertical/core/constant/NotificationConstant.java @@ -10,6 +10,4 @@ public class NotificationConstant { public static String Follow = "1"; - public static String Comment = "2"; - } diff --git a/src/main/java/com/rymcu/vertical/core/constant/ProjectConstant.java b/src/main/java/com/rymcu/vertical/core/constant/ProjectConstant.java index db5d098..96eb072 100644 --- a/src/main/java/com/rymcu/vertical/core/constant/ProjectConstant.java +++ b/src/main/java/com/rymcu/vertical/core/constant/ProjectConstant.java @@ -2,25 +2,16 @@ package com.rymcu.vertical.core.constant; /** * 项目常量 - * @author ronger */ public final class ProjectConstant { - /**当前环境*/ - public static final String ENV = "dev"; - /**项目基础包名称,根据自己公司的项目修改*/ - public static final String BASE_PACKAGE = "com.rymcu.vertical"; - /**DTO所在包*/ - public static final String DTO_PACKAGE = BASE_PACKAGE + ".dto"; - /**Model所在包*/ - public static final String MODEL_PACKAGE = BASE_PACKAGE + ".entity"; - /**Mapper所在包*/ - public static final String MAPPER_PACKAGE = BASE_PACKAGE + ".mapper"; - /**Service所在包*/ - public static final String SERVICE_PACKAGE = BASE_PACKAGE + ".service"; - /**ServiceImpl所在包*/ - public static final String SERVICE_IMPL_PACKAGE = SERVICE_PACKAGE + ".impl"; - /**Controller所在包*/ - public static final String CONTROLLER_PACKAGE = BASE_PACKAGE + ".web"; - /**Mapper插件基础接口的完全限定名*/ - public static final String MAPPER_INTERFACE_REFERENCE = BASE_PACKAGE + ".core.mapper.Mapper"; + public static final String BASE_PACKAGE = "com.rymcu.vertical";//项目基础包名称,根据自己公司的项目修改 + + public static final String DTO_PACKAGE = BASE_PACKAGE + ".dto";//DTO所在包 + public static final String MODEL_PACKAGE = BASE_PACKAGE + ".entity";//Model所在包 + public static final String MAPPER_PACKAGE = BASE_PACKAGE + ".mapper";//Mapper所在包 + public static final String SERVICE_PACKAGE = BASE_PACKAGE + ".service";//Service所在包 + public static final String SERVICE_IMPL_PACKAGE = SERVICE_PACKAGE + ".impl";//ServiceImpl所在包 + public static final String CONTROLLER_PACKAGE = BASE_PACKAGE + ".web";//Controller所在包 + + public static final String MAPPER_INTERFACE_REFERENCE = BASE_PACKAGE + ".core.mapper.Mapper";//Mapper插件基础接口的完全限定名 } diff --git a/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java b/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java index 60aa8c2..ce315ea 100644 --- a/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java +++ b/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java @@ -41,14 +41,10 @@ public class ArticleDTO { private String articlePermalink; /** 站内链接 */ private String articleLink; - /** 文章状态 */ - private String articleStatus; /** 更新时间 */ private Date updatedTime; private Author articleAuthor; private List tags; - - private List articleComments; } diff --git a/src/main/java/com/rymcu/vertical/dto/ArticleTagDTO.java b/src/main/java/com/rymcu/vertical/dto/ArticleTagDTO.java index ed69468..7eb15f7 100644 --- a/src/main/java/com/rymcu/vertical/dto/ArticleTagDTO.java +++ b/src/main/java/com/rymcu/vertical/dto/ArticleTagDTO.java @@ -7,13 +7,8 @@ import lombok.Data; */ @Data public class ArticleTagDTO { - - private Integer idArticleTag; - private Integer idTag; - private Integer idArticle; - private String tagTitle; private String tagUri; diff --git a/src/main/java/com/rymcu/vertical/dto/Author.java b/src/main/java/com/rymcu/vertical/dto/Author.java index 1f6a567..49105d7 100644 --- a/src/main/java/com/rymcu/vertical/dto/Author.java +++ b/src/main/java/com/rymcu/vertical/dto/Author.java @@ -2,9 +2,6 @@ package com.rymcu.vertical.dto; import lombok.Data; -/** - * @author ronger - */ @Data public class Author { diff --git a/src/main/java/com/rymcu/vertical/dto/CommentDTO.java b/src/main/java/com/rymcu/vertical/dto/CommentDTO.java deleted file mode 100644 index a3d2563..0000000 --- a/src/main/java/com/rymcu/vertical/dto/CommentDTO.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.rymcu.vertical.dto; - -import lombok.Data; - -import java.util.Date; - -/** - * @author ronger - */ -@Data -public class CommentDTO { - private Integer idComment; - /** 评论内容 */ - private String commentContent; - /** 作者 id */ - private Integer commentAuthorId; - /** 文章 id */ - private Integer commentArticleId; - /** 锚点 url */ - private String commentSharpUrl; - /** 父评论 id */ - private Integer commentOriginalCommentId; - /** 父评论作者头像 */ - private String commentOriginalAuthorThumbnailURL; - /** 父评论作者昵称 */ - private String commentOriginalAuthorNickname; - /** 状态 */ - private String commentStatus; - /** 0:公开回帖,1:匿名回帖 */ - private String commentAnonymous; - /** 回帖计数 */ - private Integer commentReplyCount; - /** 0:所有人可见,1:仅楼主和自己可见 */ - private String commentVisible; - /** 创建时间 */ - private Date createdTime; - - private Author commenter; - - private String timeAgo; -} diff --git a/src/main/java/com/rymcu/vertical/entity/Article.java b/src/main/java/com/rymcu/vertical/entity/Article.java index 6aefb49..e389d2c 100644 --- a/src/main/java/com/rymcu/vertical/entity/Article.java +++ b/src/main/java/com/rymcu/vertical/entity/Article.java @@ -46,6 +46,4 @@ public class Article implements Serializable,Cloneable { private Date createdTime; /** 更新时间 */ private Date updatedTime; - /** 文章状态 */ - private String articleStatus; } diff --git a/src/main/java/com/rymcu/vertical/entity/Comment.java b/src/main/java/com/rymcu/vertical/entity/Comment.java index d9b71cc..e8fb312 100644 --- a/src/main/java/com/rymcu/vertical/entity/Comment.java +++ b/src/main/java/com/rymcu/vertical/entity/Comment.java @@ -19,7 +19,7 @@ public class Comment implements Serializable,Cloneable { @Id @GeneratedValue(generator = "JDBC") @Column(name = "id") - private Integer idComment; + private Integer id; /** 评论内容 */ @Column(name = "comment_content") private String commentContent; diff --git a/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java b/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java index 959525f..71b036c 100644 --- a/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java +++ b/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java @@ -10,113 +10,34 @@ import org.apache.ibatis.annotations.Param; import java.util.List; -/** - * @author ronger - */ public interface ArticleMapper extends Mapper
{ - - /** - * 获取文章列表 - * @param searchText - * @param tag - * @return - */ List selectArticles(@Param("searchText") String searchText, @Param("tag") String tag); - /** - * 根据用户 ID 获取作者信息 - * @param id - * @return - */ Author selectAuthor(@Param("id") Integer id); - /** - * 根据文章 ID 查询文章 - * @param id - * @param type - * @return - */ - ArticleDTO selectArticleDTOById(@Param("id") Integer id, @Param("type") int type); + ArticleDTO selectArticleDTOById(@Param("id") Integer id); - /** - * 保存文章内容 - * @param idArticle - * @param articleContent - * @param articleContentHtml - * @return - */ Integer insertArticleContent(@Param("idArticle") Integer idArticle, @Param("articleContent") String articleContent, @Param("articleContentHtml") String articleContentHtml); - /** - * 更新文章内容 - * @param idArticle - * @param articleContent - * @param articleContentHtml - * @return - */ Integer updateArticleContent(@Param("idArticle") Integer idArticle, @Param("articleContent") String articleContent, @Param("articleContentHtml") String articleContentHtml); - /** - * 获取文章正文内容 - * @param idArticle - * @return - */ ArticleContent selectArticleContent(@Param("idArticle") Integer idArticle); - /** - * 获取主题下文章列表 - * @param topicName - * @return - */ List selectArticlesByTopicUri(@Param("topicName") String topicName); - /** - * 获取标签下文章列表 - * @param tagName - * @return - */ List selectArticlesByTagName(@Param("tagName") String tagName); - /** - * 获取用户文章列表 - * @param idUser - * @return - */ List selectUserArticles(@Param("idUser") Integer idUser); - /** - * 删除文章标签 - * @param id - * @return - */ Integer deleteTagArticle(@Param("id") Integer id); - /** - * 获取文章标签列表 - * @param idArticle - * @return - */ List selectTags(@Param("idArticle") Integer idArticle); /** - * 更新文章浏览数 + * * @param id * @param articleViewCount * @return */ Integer updateArticleViewCount(@Param("id") Integer id, @Param("articleViewCount") Integer articleViewCount); - - /** - * 获取草稿列表 - * @param idUser - * @return - */ - List selectDrafts(@Param("idUser") Integer idUser); - - /** - * 删除未使用的文章标签 - * @param idArticleTag - * @return - */ - Integer deleteUnusedArticleTag(@Param("idArticleTag") Integer idArticleTag); } diff --git a/src/main/java/com/rymcu/vertical/mapper/CommentMapper.java b/src/main/java/com/rymcu/vertical/mapper/CommentMapper.java deleted file mode 100644 index fba4a79..0000000 --- a/src/main/java/com/rymcu/vertical/mapper/CommentMapper.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.rymcu.vertical.mapper; - -import com.rymcu.vertical.core.mapper.Mapper; -import com.rymcu.vertical.dto.Author; -import com.rymcu.vertical.dto.CommentDTO; -import com.rymcu.vertical.entity.Comment; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -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 - * @return - */ - Integer updateCommentSharpUrl(@Param("idComment") Integer idComment, @Param("commentSharpUrl") String commentSharpUrl); -} diff --git a/src/main/java/com/rymcu/vertical/service/ArticleService.java b/src/main/java/com/rymcu/vertical/service/ArticleService.java index 541bf57..a901362 100644 --- a/src/main/java/com/rymcu/vertical/service/ArticleService.java +++ b/src/main/java/com/rymcu/vertical/service/ArticleService.java @@ -74,17 +74,4 @@ public interface ArticleService extends Service
{ * @param id */ void incrementArticleViewCount(Integer id); - - /** - * 获取分享链接数据 - * @param id - * @return - */ - Map share(Integer id) throws BaseApiException; - - /** - * 查询草稿文章类别 - * @return - */ - List findDrafts() throws BaseApiException; } diff --git a/src/main/java/com/rymcu/vertical/service/CommentService.java b/src/main/java/com/rymcu/vertical/service/CommentService.java deleted file mode 100644 index 5324a42..0000000 --- a/src/main/java/com/rymcu/vertical/service/CommentService.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.rymcu.vertical.service; - -import com.rymcu.vertical.core.service.Service; -import com.rymcu.vertical.dto.CommentDTO; -import com.rymcu.vertical.entity.Comment; - -import javax.servlet.http.HttpServletRequest; -import java.util.List; -import java.util.Map; - -public interface CommentService extends Service { - - List getArticleComments(Integer idArticle); - - Map postComment(Comment comment, HttpServletRequest request); -} 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 f451556..1178ab0 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java @@ -1,19 +1,16 @@ package com.rymcu.vertical.service.impl; import com.rymcu.vertical.core.constant.NotificationConstant; -import com.rymcu.vertical.core.constant.ProjectConstant; import com.rymcu.vertical.core.service.AbstractService; import com.rymcu.vertical.dto.ArticleDTO; import com.rymcu.vertical.dto.ArticleTagDTO; import com.rymcu.vertical.dto.Author; -import com.rymcu.vertical.dto.CommentDTO; import com.rymcu.vertical.entity.Article; import com.rymcu.vertical.entity.ArticleContent; import com.rymcu.vertical.entity.Tag; import com.rymcu.vertical.entity.User; import com.rymcu.vertical.mapper.ArticleMapper; import com.rymcu.vertical.service.ArticleService; -import com.rymcu.vertical.service.CommentService; import com.rymcu.vertical.service.TagService; import com.rymcu.vertical.service.UserService; import com.rymcu.vertical.util.*; @@ -45,16 +42,11 @@ public class ArticleServiceImpl extends AbstractService
implements Arti private TagService tagService; @Resource private UserService userService; - @Resource - private CommentService commentService; @Value("${resource.domain}") - private String domain; - @Value("${env}") - private String env; + private static String domain; private static final int MAX_PREVIEW = 200; - private static final String defaultStatus = "0"; @Override public List findArticles(String searchText, String tag) { @@ -67,10 +59,7 @@ public class ArticleServiceImpl extends AbstractService
implements Arti @Override public ArticleDTO findArticleDTOById(Integer id, int type) { - ArticleDTO articleDTO = articleMapper.selectArticleDTOById(id,type); - if (articleDTO == null) { - return null; - } + ArticleDTO articleDTO = articleMapper.selectArticleDTOById(id); articleDTO = genArticle(articleDTO,type); return articleDTO; } @@ -132,12 +121,11 @@ public class ArticleServiceImpl extends AbstractService
implements Arti newArticle.setArticleTags(articleTags); newArticle.setCreatedTime(new Date()); newArticle.setUpdatedTime(newArticle.getCreatedTime()); - newArticle.setArticleStatus(article.getArticleStatus()); articleMapper.insertSelective(newArticle); + newArticle.setArticlePermalink(domain + "/article/"+newArticle.getIdArticle()); + newArticle.setArticleLink("/article/"+newArticle.getIdArticle()); articleMapper.insertArticleContent(newArticle.getIdArticle(),articleContent,articleContentHtml); - if (!ProjectConstant.ENV.equals(env) && defaultStatus.equals(newArticle.getArticleStatus())) { - BaiDuUtils.sendSEOData(newArticle.getArticlePermalink()); - } + BaiDuUtils.sendSEOData(newArticle.getArticlePermalink()); } else { newArticle = articleMapper.selectByPrimaryKey(article.getIdArticle()); if(!user.getIdUser().equals(newArticle.getArticleAuthorId())){ @@ -154,27 +142,16 @@ public class ArticleServiceImpl extends AbstractService
implements Arti String articlePreviewContent = articleContentHtml.substring(0,length); newArticle.setArticlePreviewContent(Html2TextUtil.getContent(articlePreviewContent)); } - newArticle.setArticleStatus(article.getArticleStatus()); newArticle.setUpdatedTime(new Date()); articleMapper.updateArticleContent(newArticle.getIdArticle(),articleContent,articleContentHtml); - if (!ProjectConstant.ENV.equals(env) && defaultStatus.equals(newArticle.getArticleStatus())) { - BaiDuUtils.updateSEOData(newArticle.getArticlePermalink()); - } + BaiDuUtils.updateSEOData(newArticle.getArticlePermalink()); } - if (notification && defaultStatus.equals(newArticle.getArticleStatus())) { + if (notification) { NotificationUtils.sendAnnouncement(newArticle.getIdArticle(), NotificationConstant.Article, newArticle.getArticleTitle()); } tagService.saveTagArticle(newArticle); - - if (defaultStatus.equals(newArticle.getArticleStatus())) { - newArticle.setArticlePermalink(domain + "/article/" + newArticle.getIdArticle()); - newArticle.setArticleLink("/article/" + newArticle.getIdArticle()); - } else { - newArticle.setArticlePermalink(domain + "/draft/" + newArticle.getIdArticle()); - newArticle.setArticleLink("/draft/" + newArticle.getIdArticle()); - } articleMapper.updateByPrimaryKeySelective(newArticle); map.put("id", newArticle.getIdArticle()); @@ -239,27 +216,6 @@ public class ArticleServiceImpl extends AbstractService
implements Arti articleMapper.updateArticleViewCount(article.getIdArticle(), articleViewCount); } - @Override - public Map share(Integer id) throws BaseApiException { - Article article = articleMapper.selectByPrimaryKey(id); - User user = UserUtils.getWxCurrentUser(); - StringBuilder shareUrl = new StringBuilder(article.getArticlePermalink()); - shareUrl.append("?s=").append(user.getNickname()); - Map map = new HashMap(1); - map.put("shareUrl", shareUrl); - return map; - } - - @Override - public List findDrafts() throws BaseApiException { - User user = UserUtils.getWxCurrentUser(); - List list = articleMapper.selectDrafts(user.getIdUser()); - list.forEach(article->{ - genArticle(article,0); - }); - return list; - } - private ArticleDTO genArticle(ArticleDTO article,Integer type) { Author author = articleMapper.selectAuthor(article.getArticleAuthorId()); article.setArticleAuthor(author); @@ -283,8 +239,6 @@ public class ArticleServiceImpl extends AbstractService
implements Arti String articlePreviewContent = articleContent.getArticleContentHtml().substring(0,length); article.setArticlePreviewContent(Html2TextUtil.getContent(articlePreviewContent)); } - List commentDTOList = commentService.getArticleComments(article.getIdArticle()); - article.setArticleComments(commentDTOList); return article; } } diff --git a/src/main/java/com/rymcu/vertical/service/impl/CommentServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/CommentServiceImpl.java deleted file mode 100644 index f7268e1..0000000 --- a/src/main/java/com/rymcu/vertical/service/impl/CommentServiceImpl.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.rymcu.vertical.service.impl; - -import com.rymcu.vertical.core.constant.NotificationConstant; -import com.rymcu.vertical.core.service.AbstractService; -import com.rymcu.vertical.dto.Author; -import com.rymcu.vertical.dto.CommentDTO; -import com.rymcu.vertical.entity.Article; -import com.rymcu.vertical.entity.Comment; -import com.rymcu.vertical.mapper.CommentMapper; -import com.rymcu.vertical.service.ArticleService; -import com.rymcu.vertical.service.CommentService; -import com.rymcu.vertical.util.Html2TextUtil; -import com.rymcu.vertical.util.NotificationUtils; -import com.rymcu.vertical.util.Utils; -import org.apache.commons.lang.StringUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import java.util.*; - -/** - * @author ronger - */ -@Service -public class CommentServiceImpl extends AbstractService implements CommentService { - - @Resource - private CommentMapper commentMapper; - @Resource - private ArticleService articleService; - - private static final int MAX_PREVIEW = 200; - - @Override - public List getArticleComments(Integer idArticle) { - List commentDTOList = commentMapper.selectArticleComments(idArticle); - commentDTOList.forEach(commentDTO -> { - commentDTO.setTimeAgo(Utils.getTimeAgo(commentDTO.getCreatedTime())); - if (commentDTO.getCommentAuthorId() != null) { - Author author = commentMapper.selectAuthor(commentDTO.getCommentAuthorId()); - if (author != null) { - commentDTO.setCommenter(author); - } - } - if (commentDTO.getCommentOriginalCommentId() != null) { - Author commentOriginalAuthor = commentMapper.selectCommentOriginalAuthor(commentDTO.getCommentOriginalCommentId()); - if (commentOriginalAuthor != null) { - commentDTO.setCommentOriginalAuthorThumbnailURL(commentOriginalAuthor.getUserAvatarURL()); - commentDTO.setCommentOriginalAuthorNickname(commentOriginalAuthor.getUserNickname()); - } - } - }); - return commentDTOList; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public Map postComment(Comment comment, HttpServletRequest request) { - Map map = new HashMap(1); - if(comment.getCommentArticleId() == null){ - map.put("message","非法访问,文章主键异常!"); - return map; - } - if(comment.getCommentAuthorId() == null){ - map.put("message","非法访问,用户未登录!"); - return map; - } - if(StringUtils.isBlank(comment.getCommentContent())){ - map.put("message","回帖内容不能为空!"); - return map; - } - Article article = articleService.findById(comment.getCommentArticleId().toString()); - if (article == null) { - map.put("message","文章不存在!"); - return map; - } - String ip = Utils.getIpAddress(request); - String ua = request.getHeader("user-agent"); - comment.setCommentIP(ip); - comment.setCommentUA(ua); - comment.setCreatedTime(new Date()); - commentMapper.insertSelective(comment); - StringBuilder commentSharpUrl = new StringBuilder(article.getArticlePermalink()); - commentSharpUrl.append("/comment/").append(comment.getIdComment()); - commentMapper.updateCommentSharpUrl(comment.getIdComment(), commentSharpUrl.toString()); - - String commentContent = comment.getCommentContent(); - if(StringUtils.isNotBlank(commentContent)){ - Integer length = commentContent.length(); - if(length > MAX_PREVIEW){ - length = 200; - } - String commentPreviewContent = commentContent.substring(0,length); - commentContent = Html2TextUtil.getContent(commentPreviewContent); - // 评论者不是作者本人则进行消息通知 - if (!article.getArticleAuthorId().equals(comment.getCommentAuthorId())) { - NotificationUtils.saveNotification(article.getArticleAuthorId(),comment.getIdComment(), NotificationConstant.Comment, commentContent); - } - // 判断是否是回复消息 - if (comment.getCommentOriginalCommentId() != null && comment.getCommentOriginalCommentId() != 0) { - Comment originalComment = commentMapper.selectByPrimaryKey(comment.getCommentOriginalCommentId()); - // 回复消息时,评论者不是上级评论作者则进行消息通知 - if (!comment.getCommentAuthorId().equals(originalComment.getCommentAuthorId())) { - NotificationUtils.saveNotification(originalComment.getCommentAuthorId(),comment.getIdComment(), NotificationConstant.Comment, commentContent); - } - } - } - - - return map; - } -} diff --git a/src/main/java/com/rymcu/vertical/service/impl/TagServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/TagServiceImpl.java index d58eed3..4c02be0 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/TagServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/TagServiceImpl.java @@ -1,11 +1,9 @@ package com.rymcu.vertical.service.impl; import com.rymcu.vertical.core.service.AbstractService; -import com.rymcu.vertical.dto.ArticleTagDTO; import com.rymcu.vertical.entity.Article; import com.rymcu.vertical.entity.Tag; import com.rymcu.vertical.entity.User; -import com.rymcu.vertical.mapper.ArticleMapper; import com.rymcu.vertical.mapper.TagMapper; import com.rymcu.vertical.service.TagService; import com.rymcu.vertical.util.UserUtils; @@ -31,8 +29,6 @@ public class TagServiceImpl extends AbstractService implements TagService { @Resource private TagMapper tagMapper; - @Resource - private ArticleMapper articleMapper; @Override @Transactional(rollbackFor = { UnsupportedEncodingException.class,BaseApiException.class }) @@ -41,7 +37,6 @@ public class TagServiceImpl extends AbstractService implements TagService { String articleTags = article.getArticleTags(); if(StringUtils.isNotBlank(articleTags)){ String[] tags = articleTags.split(","); - List articleTagDTOList = articleMapper.selectTags(article.getIdArticle()); for (int i = 0; i < tags.length; i++) { boolean addTagArticle = false; boolean addUserTag = false; @@ -59,12 +54,6 @@ public class TagServiceImpl extends AbstractService implements TagService { addTagArticle = true; addUserTag = true; } else { - for(int m=0,n=articleTagDTOList.size()-1;m implements TagService { addUserTag = true; } } - articleTagDTOList.forEach(articleTagDTO -> { - articleMapper.deleteUnusedArticleTag(articleTagDTO.getIdArticleTag()); - }); if(addTagArticle){ tagMapper.insertTagArticle(tag.getIdTag(),article.getIdArticle()); } diff --git a/src/main/java/com/rymcu/vertical/util/BaiDuUtils.java b/src/main/java/com/rymcu/vertical/util/BaiDuUtils.java index 83e015f..5e83cd0 100644 --- a/src/main/java/com/rymcu/vertical/util/BaiDuUtils.java +++ b/src/main/java/com/rymcu/vertical/util/BaiDuUtils.java @@ -33,29 +33,6 @@ public class BaiDuUtils { } return 0; },executor); - return; - } - - public static void sendUpdateSEOData(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); - return; } public static void updateSEOData(String permalink) { @@ -100,7 +77,7 @@ public class BaiDuUtils { },executor); } - public static void main(){ - sendUpdateSEOData("https://rymcu.com"); + public static void main(String agrs[]){ + sendSEOData("https://rymcu.com/article/31"); } } diff --git a/src/main/java/com/rymcu/vertical/util/NotificationUtils.java b/src/main/java/com/rymcu/vertical/util/NotificationUtils.java index 7a42c0c..112f20b 100644 --- a/src/main/java/com/rymcu/vertical/util/NotificationUtils.java +++ b/src/main/java/com/rymcu/vertical/util/NotificationUtils.java @@ -42,7 +42,7 @@ public class NotificationUtils { },executor); } - public static void saveNotification(Integer idUser, Integer dataId, String dataType, String dataSummary) { + private static void saveNotification(Integer idUser, Integer dataId, String dataType, String dataSummary) { ExecutorService executor= new ThreadPoolExecutor(1,1,0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue()); CompletableFuture.supplyAsync(()-> { try { diff --git a/src/main/java/com/rymcu/vertical/web/api/article/ArticleController.java b/src/main/java/com/rymcu/vertical/web/api/article/ArticleController.java index 8fa3f41..631e1c5 100644 --- a/src/main/java/com/rymcu/vertical/web/api/article/ArticleController.java +++ b/src/main/java/com/rymcu/vertical/web/api/article/ArticleController.java @@ -1,14 +1,9 @@ package com.rymcu.vertical.web.api.article; -import com.github.pagehelper.PageHelper; -import com.github.pagehelper.PageInfo; 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.CommentDTO; import com.rymcu.vertical.service.ArticleService; -import com.rymcu.vertical.service.CommentService; -import com.rymcu.vertical.util.Utils; import com.rymcu.vertical.web.api.exception.BaseApiException; import org.springframework.web.bind.annotation.*; @@ -16,7 +11,6 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.io.UnsupportedEncodingException; import java.util.HashMap; -import java.util.List; import java.util.Map; /** @@ -28,8 +22,6 @@ public class ArticleController { @Resource private ArticleService articleService; - @Resource - private CommentService commentService; @@ -59,27 +51,4 @@ public class ArticleController { return GlobalResultGenerator.genSuccessResult(map); } - @GetMapping("/{id}/comments") - public GlobalResult> commons(@PathVariable Integer id){ - List commentDTOList = commentService.getArticleComments(id); - Map map = new HashMap<>(1); - map.put("comments", commentDTOList); - return GlobalResultGenerator.genSuccessResult(map); - } - - @GetMapping("/drafts") - public GlobalResult drafts(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) throws BaseApiException { - PageHelper.startPage(page, rows); - List list = articleService.findDrafts(); - PageInfo pageInfo = new PageInfo(list); - Map map = Utils.getArticlesGlobalResult(pageInfo); - return GlobalResultGenerator.genSuccessResult(map); - } - - @GetMapping("/{id}/share") - public GlobalResult share(@PathVariable Integer id) throws BaseApiException { - Map map = articleService.share(id); - return GlobalResultGenerator.genSuccessResult(map); - } - } diff --git a/src/main/java/com/rymcu/vertical/web/api/comment/CommentController.java b/src/main/java/com/rymcu/vertical/web/api/comment/CommentController.java deleted file mode 100644 index 814b625..0000000 --- a/src/main/java/com/rymcu/vertical/web/api/comment/CommentController.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.rymcu.vertical.web.api.comment; - -import com.rymcu.vertical.core.result.GlobalResult; -import com.rymcu.vertical.core.result.GlobalResultGenerator; -import com.rymcu.vertical.dto.ArticleDTO; -import com.rymcu.vertical.entity.Comment; -import com.rymcu.vertical.service.CommentService; -import com.rymcu.vertical.web.api.exception.BaseApiException; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import java.io.UnsupportedEncodingException; -import java.util.Map; - -/** - * @author ronger - */ -@RestController -@RequestMapping("/api/v1/comment") -public class CommentController { - - @Resource - private CommentService commentService; - - @PostMapping("/post") - public GlobalResult postComment(@RequestBody Comment comment, HttpServletRequest request) throws BaseApiException, UnsupportedEncodingException { - Map map = commentService.postComment(comment,request); - return GlobalResultGenerator.genSuccessResult(map); - } -} diff --git a/src/main/java/mapper/ArticleMapper.xml b/src/main/java/mapper/ArticleMapper.xml index e315b78..65d0423 100644 --- a/src/main/java/mapper/ArticleMapper.xml +++ b/src/main/java/mapper/ArticleMapper.xml @@ -35,7 +35,6 @@ - @@ -51,13 +50,11 @@ - - - - - - - + + + + + insert into vertical_article_content (id_article,article_content,article_content_html,created_time,updated_time) @@ -72,20 +69,14 @@ delete from vertical_tag_article where id_article = #{id} - - delete from vertical_tag_article where id = #{idArticleTag} - - \ No newline at end of file diff --git a/src/main/java/mapper/CommentMapper.xml b/src/main/java/mapper/CommentMapper.xml deleted file mode 100644 index cbc5cbc..0000000 --- a/src/main/java/mapper/CommentMapper.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - update vertical_comment set comment_sharp_url = #{commentSharpUrl} where id = #{idComment} - - - - - \ No newline at end of file diff --git a/src/main/java/mapper/RoleMapper.xml b/src/main/java/mapper/RoleMapper.xml index 95b5c0f..7967a39 100644 --- a/src/main/java/mapper/RoleMapper.xml +++ b/src/main/java/mapper/RoleMapper.xml @@ -17,7 +17,7 @@ update vertical_role set status = #{status},updated_time = sysdate() where id = #{idRole} - update vertical_role set name = #{name}, input_code = #{inputCode}, weights = #{weights}, updated_time = sysdate() where id = #{idRole} + update vertical_role set name = #{name}, input_code = ${inputCode}, weights = #{weights}, updated_time = sysdate() where id = #{idRole}