Revert "新功能发布,缺陷代码修复,用户体验提升"
This commit is contained in:
parent
1a632d790b
commit
d74d470597
@ -10,6 +10,4 @@ public class NotificationConstant {
|
|||||||
|
|
||||||
public static String Follow = "1";
|
public static String Follow = "1";
|
||||||
|
|
||||||
public static String Comment = "2";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,25 +2,16 @@ package com.rymcu.vertical.core.constant;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 项目常量
|
* 项目常量
|
||||||
* @author ronger
|
|
||||||
*/
|
*/
|
||||||
public final class ProjectConstant {
|
public final class ProjectConstant {
|
||||||
/**当前环境*/
|
public static final String BASE_PACKAGE = "com.rymcu.vertical";//项目基础包名称,根据自己公司的项目修改
|
||||||
public static final String ENV = "dev";
|
|
||||||
/**项目基础包名称,根据自己公司的项目修改*/
|
public static final String DTO_PACKAGE = BASE_PACKAGE + ".dto";//DTO所在包
|
||||||
public static final String BASE_PACKAGE = "com.rymcu.vertical";
|
public static final String MODEL_PACKAGE = BASE_PACKAGE + ".entity";//Model所在包
|
||||||
/**DTO所在包*/
|
public static final String MAPPER_PACKAGE = BASE_PACKAGE + ".mapper";//Mapper所在包
|
||||||
public static final String DTO_PACKAGE = BASE_PACKAGE + ".dto";
|
public static final String SERVICE_PACKAGE = BASE_PACKAGE + ".service";//Service所在包
|
||||||
/**Model所在包*/
|
public static final String SERVICE_IMPL_PACKAGE = SERVICE_PACKAGE + ".impl";//ServiceImpl所在包
|
||||||
public static final String MODEL_PACKAGE = BASE_PACKAGE + ".entity";
|
public static final String CONTROLLER_PACKAGE = BASE_PACKAGE + ".web";//Controller所在包
|
||||||
/**Mapper所在包*/
|
|
||||||
public static final String MAPPER_PACKAGE = BASE_PACKAGE + ".mapper";
|
public static final String MAPPER_INTERFACE_REFERENCE = BASE_PACKAGE + ".core.mapper.Mapper";//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";
|
|
||||||
}
|
}
|
||||||
|
@ -41,14 +41,10 @@ public class ArticleDTO {
|
|||||||
private String articlePermalink;
|
private String articlePermalink;
|
||||||
/** 站内链接 */
|
/** 站内链接 */
|
||||||
private String articleLink;
|
private String articleLink;
|
||||||
/** 文章状态 */
|
|
||||||
private String articleStatus;
|
|
||||||
/** 更新时间 */
|
/** 更新时间 */
|
||||||
private Date updatedTime;
|
private Date updatedTime;
|
||||||
|
|
||||||
private Author articleAuthor;
|
private Author articleAuthor;
|
||||||
|
|
||||||
private List<ArticleTagDTO> tags;
|
private List<ArticleTagDTO> tags;
|
||||||
|
|
||||||
private List<CommentDTO> articleComments;
|
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,8 @@ import lombok.Data;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class ArticleTagDTO {
|
public class ArticleTagDTO {
|
||||||
|
|
||||||
private Integer idArticleTag;
|
|
||||||
|
|
||||||
private Integer idTag;
|
private Integer idTag;
|
||||||
|
|
||||||
private Integer idArticle;
|
|
||||||
|
|
||||||
private String tagTitle;
|
private String tagTitle;
|
||||||
|
|
||||||
private String tagUri;
|
private String tagUri;
|
||||||
|
@ -2,9 +2,6 @@ package com.rymcu.vertical.dto;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ronger
|
|
||||||
*/
|
|
||||||
@Data
|
@Data
|
||||||
public class Author {
|
public class Author {
|
||||||
|
|
||||||
|
@ -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;
|
|
||||||
}
|
|
@ -46,6 +46,4 @@ public class Article implements Serializable,Cloneable {
|
|||||||
private Date createdTime;
|
private Date createdTime;
|
||||||
/** 更新时间 */
|
/** 更新时间 */
|
||||||
private Date updatedTime;
|
private Date updatedTime;
|
||||||
/** 文章状态 */
|
|
||||||
private String articleStatus;
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ public class Comment implements Serializable,Cloneable {
|
|||||||
@Id
|
@Id
|
||||||
@GeneratedValue(generator = "JDBC")
|
@GeneratedValue(generator = "JDBC")
|
||||||
@Column(name = "id")
|
@Column(name = "id")
|
||||||
private Integer idComment;
|
private Integer id;
|
||||||
/** 评论内容 */
|
/** 评论内容 */
|
||||||
@Column(name = "comment_content")
|
@Column(name = "comment_content")
|
||||||
private String commentContent;
|
private String commentContent;
|
||||||
|
@ -10,113 +10,34 @@ import org.apache.ibatis.annotations.Param;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ronger
|
|
||||||
*/
|
|
||||||
public interface ArticleMapper extends Mapper<Article> {
|
public interface ArticleMapper extends Mapper<Article> {
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取文章列表
|
|
||||||
* @param searchText
|
|
||||||
* @param tag
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<ArticleDTO> selectArticles(@Param("searchText") String searchText, @Param("tag") String tag);
|
List<ArticleDTO> selectArticles(@Param("searchText") String searchText, @Param("tag") String tag);
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据用户 ID 获取作者信息
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Author selectAuthor(@Param("id") Integer id);
|
Author selectAuthor(@Param("id") Integer id);
|
||||||
|
|
||||||
/**
|
ArticleDTO selectArticleDTOById(@Param("id") Integer id);
|
||||||
* 根据文章 ID 查询文章
|
|
||||||
* @param id
|
|
||||||
* @param type
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ArticleDTO selectArticleDTOById(@Param("id") Integer id, @Param("type") int type);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存文章内容
|
|
||||||
* @param idArticle
|
|
||||||
* @param articleContent
|
|
||||||
* @param articleContentHtml
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer insertArticleContent(@Param("idArticle") Integer idArticle, @Param("articleContent") String articleContent, @Param("articleContentHtml") String articleContentHtml);
|
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);
|
Integer updateArticleContent(@Param("idArticle") Integer idArticle, @Param("articleContent") String articleContent, @Param("articleContentHtml") String articleContentHtml);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取文章正文内容
|
|
||||||
* @param idArticle
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ArticleContent selectArticleContent(@Param("idArticle") Integer idArticle);
|
ArticleContent selectArticleContent(@Param("idArticle") Integer idArticle);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主题下文章列表
|
|
||||||
* @param topicName
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<ArticleDTO> selectArticlesByTopicUri(@Param("topicName") String topicName);
|
List<ArticleDTO> selectArticlesByTopicUri(@Param("topicName") String topicName);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取标签下文章列表
|
|
||||||
* @param tagName
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<ArticleDTO> selectArticlesByTagName(@Param("tagName") String tagName);
|
List<ArticleDTO> selectArticlesByTagName(@Param("tagName") String tagName);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取用户文章列表
|
|
||||||
* @param idUser
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<ArticleDTO> selectUserArticles(@Param("idUser") Integer idUser);
|
List<ArticleDTO> selectUserArticles(@Param("idUser") Integer idUser);
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除文章标签
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer deleteTagArticle(@Param("id") Integer id);
|
Integer deleteTagArticle(@Param("id") Integer id);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取文章标签列表
|
|
||||||
* @param idArticle
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<ArticleTagDTO> selectTags(@Param("idArticle") Integer idArticle);
|
List<ArticleTagDTO> selectTags(@Param("idArticle") Integer idArticle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新文章浏览数
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @param articleViewCount
|
* @param articleViewCount
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Integer updateArticleViewCount(@Param("id") Integer id, @Param("articleViewCount") Integer articleViewCount);
|
Integer updateArticleViewCount(@Param("id") Integer id, @Param("articleViewCount") Integer articleViewCount);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取草稿列表
|
|
||||||
* @param idUser
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<ArticleDTO> selectDrafts(@Param("idUser") Integer idUser);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除未使用的文章标签
|
|
||||||
* @param idArticleTag
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer deleteUnusedArticleTag(@Param("idArticleTag") Integer idArticleTag);
|
|
||||||
}
|
}
|
||||||
|
@ -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<Comment> {
|
|
||||||
/**
|
|
||||||
* @param idArticle
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<CommentDTO> 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);
|
|
||||||
}
|
|
@ -74,17 +74,4 @@ public interface ArticleService extends Service<Article> {
|
|||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
void incrementArticleViewCount(Integer id);
|
void incrementArticleViewCount(Integer id);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取分享链接数据
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Map share(Integer id) throws BaseApiException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询草稿文章类别
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<ArticleDTO> findDrafts() throws BaseApiException;
|
|
||||||
}
|
}
|
||||||
|
@ -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<Comment> {
|
|
||||||
|
|
||||||
List<CommentDTO> getArticleComments(Integer idArticle);
|
|
||||||
|
|
||||||
Map postComment(Comment comment, HttpServletRequest request);
|
|
||||||
}
|
|
@ -1,19 +1,16 @@
|
|||||||
package com.rymcu.vertical.service.impl;
|
package com.rymcu.vertical.service.impl;
|
||||||
|
|
||||||
import com.rymcu.vertical.core.constant.NotificationConstant;
|
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.core.service.AbstractService;
|
||||||
import com.rymcu.vertical.dto.ArticleDTO;
|
import com.rymcu.vertical.dto.ArticleDTO;
|
||||||
import com.rymcu.vertical.dto.ArticleTagDTO;
|
import com.rymcu.vertical.dto.ArticleTagDTO;
|
||||||
import com.rymcu.vertical.dto.Author;
|
import com.rymcu.vertical.dto.Author;
|
||||||
import com.rymcu.vertical.dto.CommentDTO;
|
|
||||||
import com.rymcu.vertical.entity.Article;
|
import com.rymcu.vertical.entity.Article;
|
||||||
import com.rymcu.vertical.entity.ArticleContent;
|
import com.rymcu.vertical.entity.ArticleContent;
|
||||||
import com.rymcu.vertical.entity.Tag;
|
import com.rymcu.vertical.entity.Tag;
|
||||||
import com.rymcu.vertical.entity.User;
|
import com.rymcu.vertical.entity.User;
|
||||||
import com.rymcu.vertical.mapper.ArticleMapper;
|
import com.rymcu.vertical.mapper.ArticleMapper;
|
||||||
import com.rymcu.vertical.service.ArticleService;
|
import com.rymcu.vertical.service.ArticleService;
|
||||||
import com.rymcu.vertical.service.CommentService;
|
|
||||||
import com.rymcu.vertical.service.TagService;
|
import com.rymcu.vertical.service.TagService;
|
||||||
import com.rymcu.vertical.service.UserService;
|
import com.rymcu.vertical.service.UserService;
|
||||||
import com.rymcu.vertical.util.*;
|
import com.rymcu.vertical.util.*;
|
||||||
@ -45,16 +42,11 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
private TagService tagService;
|
private TagService tagService;
|
||||||
@Resource
|
@Resource
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
@Resource
|
|
||||||
private CommentService commentService;
|
|
||||||
|
|
||||||
@Value("${resource.domain}")
|
@Value("${resource.domain}")
|
||||||
private String domain;
|
private static String domain;
|
||||||
@Value("${env}")
|
|
||||||
private String env;
|
|
||||||
|
|
||||||
private static final int MAX_PREVIEW = 200;
|
private static final int MAX_PREVIEW = 200;
|
||||||
private static final String defaultStatus = "0";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ArticleDTO> findArticles(String searchText, String tag) {
|
public List<ArticleDTO> findArticles(String searchText, String tag) {
|
||||||
@ -67,10 +59,7 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArticleDTO findArticleDTOById(Integer id, int type) {
|
public ArticleDTO findArticleDTOById(Integer id, int type) {
|
||||||
ArticleDTO articleDTO = articleMapper.selectArticleDTOById(id,type);
|
ArticleDTO articleDTO = articleMapper.selectArticleDTOById(id);
|
||||||
if (articleDTO == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
articleDTO = genArticle(articleDTO,type);
|
articleDTO = genArticle(articleDTO,type);
|
||||||
return articleDTO;
|
return articleDTO;
|
||||||
}
|
}
|
||||||
@ -132,12 +121,11 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
newArticle.setArticleTags(articleTags);
|
newArticle.setArticleTags(articleTags);
|
||||||
newArticle.setCreatedTime(new Date());
|
newArticle.setCreatedTime(new Date());
|
||||||
newArticle.setUpdatedTime(newArticle.getCreatedTime());
|
newArticle.setUpdatedTime(newArticle.getCreatedTime());
|
||||||
newArticle.setArticleStatus(article.getArticleStatus());
|
|
||||||
articleMapper.insertSelective(newArticle);
|
articleMapper.insertSelective(newArticle);
|
||||||
|
newArticle.setArticlePermalink(domain + "/article/"+newArticle.getIdArticle());
|
||||||
|
newArticle.setArticleLink("/article/"+newArticle.getIdArticle());
|
||||||
articleMapper.insertArticleContent(newArticle.getIdArticle(),articleContent,articleContentHtml);
|
articleMapper.insertArticleContent(newArticle.getIdArticle(),articleContent,articleContentHtml);
|
||||||
if (!ProjectConstant.ENV.equals(env) && defaultStatus.equals(newArticle.getArticleStatus())) {
|
BaiDuUtils.sendSEOData(newArticle.getArticlePermalink());
|
||||||
BaiDuUtils.sendSEOData(newArticle.getArticlePermalink());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
newArticle = articleMapper.selectByPrimaryKey(article.getIdArticle());
|
newArticle = articleMapper.selectByPrimaryKey(article.getIdArticle());
|
||||||
if(!user.getIdUser().equals(newArticle.getArticleAuthorId())){
|
if(!user.getIdUser().equals(newArticle.getArticleAuthorId())){
|
||||||
@ -154,27 +142,16 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
String articlePreviewContent = articleContentHtml.substring(0,length);
|
String articlePreviewContent = articleContentHtml.substring(0,length);
|
||||||
newArticle.setArticlePreviewContent(Html2TextUtil.getContent(articlePreviewContent));
|
newArticle.setArticlePreviewContent(Html2TextUtil.getContent(articlePreviewContent));
|
||||||
}
|
}
|
||||||
newArticle.setArticleStatus(article.getArticleStatus());
|
|
||||||
newArticle.setUpdatedTime(new Date());
|
newArticle.setUpdatedTime(new Date());
|
||||||
articleMapper.updateArticleContent(newArticle.getIdArticle(),articleContent,articleContentHtml);
|
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());
|
NotificationUtils.sendAnnouncement(newArticle.getIdArticle(), NotificationConstant.Article, newArticle.getArticleTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
tagService.saveTagArticle(newArticle);
|
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);
|
articleMapper.updateByPrimaryKeySelective(newArticle);
|
||||||
|
|
||||||
map.put("id", newArticle.getIdArticle());
|
map.put("id", newArticle.getIdArticle());
|
||||||
@ -239,27 +216,6 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
articleMapper.updateArticleViewCount(article.getIdArticle(), articleViewCount);
|
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<ArticleDTO> findDrafts() throws BaseApiException {
|
|
||||||
User user = UserUtils.getWxCurrentUser();
|
|
||||||
List<ArticleDTO> list = articleMapper.selectDrafts(user.getIdUser());
|
|
||||||
list.forEach(article->{
|
|
||||||
genArticle(article,0);
|
|
||||||
});
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArticleDTO genArticle(ArticleDTO article,Integer type) {
|
private ArticleDTO genArticle(ArticleDTO article,Integer type) {
|
||||||
Author author = articleMapper.selectAuthor(article.getArticleAuthorId());
|
Author author = articleMapper.selectAuthor(article.getArticleAuthorId());
|
||||||
article.setArticleAuthor(author);
|
article.setArticleAuthor(author);
|
||||||
@ -283,8 +239,6 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
String articlePreviewContent = articleContent.getArticleContentHtml().substring(0,length);
|
String articlePreviewContent = articleContent.getArticleContentHtml().substring(0,length);
|
||||||
article.setArticlePreviewContent(Html2TextUtil.getContent(articlePreviewContent));
|
article.setArticlePreviewContent(Html2TextUtil.getContent(articlePreviewContent));
|
||||||
}
|
}
|
||||||
List<CommentDTO> commentDTOList = commentService.getArticleComments(article.getIdArticle());
|
|
||||||
article.setArticleComments(commentDTOList);
|
|
||||||
return article;
|
return article;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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<Comment> implements CommentService {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private CommentMapper commentMapper;
|
|
||||||
@Resource
|
|
||||||
private ArticleService articleService;
|
|
||||||
|
|
||||||
private static final int MAX_PREVIEW = 200;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<CommentDTO> getArticleComments(Integer idArticle) {
|
|
||||||
List<CommentDTO> 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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +1,9 @@
|
|||||||
package com.rymcu.vertical.service.impl;
|
package com.rymcu.vertical.service.impl;
|
||||||
|
|
||||||
import com.rymcu.vertical.core.service.AbstractService;
|
import com.rymcu.vertical.core.service.AbstractService;
|
||||||
import com.rymcu.vertical.dto.ArticleTagDTO;
|
|
||||||
import com.rymcu.vertical.entity.Article;
|
import com.rymcu.vertical.entity.Article;
|
||||||
import com.rymcu.vertical.entity.Tag;
|
import com.rymcu.vertical.entity.Tag;
|
||||||
import com.rymcu.vertical.entity.User;
|
import com.rymcu.vertical.entity.User;
|
||||||
import com.rymcu.vertical.mapper.ArticleMapper;
|
|
||||||
import com.rymcu.vertical.mapper.TagMapper;
|
import com.rymcu.vertical.mapper.TagMapper;
|
||||||
import com.rymcu.vertical.service.TagService;
|
import com.rymcu.vertical.service.TagService;
|
||||||
import com.rymcu.vertical.util.UserUtils;
|
import com.rymcu.vertical.util.UserUtils;
|
||||||
@ -31,8 +29,6 @@ public class TagServiceImpl extends AbstractService<Tag> implements TagService {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private TagMapper tagMapper;
|
private TagMapper tagMapper;
|
||||||
@Resource
|
|
||||||
private ArticleMapper articleMapper;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = { UnsupportedEncodingException.class,BaseApiException.class })
|
@Transactional(rollbackFor = { UnsupportedEncodingException.class,BaseApiException.class })
|
||||||
@ -41,7 +37,6 @@ public class TagServiceImpl extends AbstractService<Tag> implements TagService {
|
|||||||
String articleTags = article.getArticleTags();
|
String articleTags = article.getArticleTags();
|
||||||
if(StringUtils.isNotBlank(articleTags)){
|
if(StringUtils.isNotBlank(articleTags)){
|
||||||
String[] tags = articleTags.split(",");
|
String[] tags = articleTags.split(",");
|
||||||
List<ArticleTagDTO> articleTagDTOList = articleMapper.selectTags(article.getIdArticle());
|
|
||||||
for (int i = 0; i < tags.length; i++) {
|
for (int i = 0; i < tags.length; i++) {
|
||||||
boolean addTagArticle = false;
|
boolean addTagArticle = false;
|
||||||
boolean addUserTag = false;
|
boolean addUserTag = false;
|
||||||
@ -59,12 +54,6 @@ public class TagServiceImpl extends AbstractService<Tag> implements TagService {
|
|||||||
addTagArticle = true;
|
addTagArticle = true;
|
||||||
addUserTag = true;
|
addUserTag = true;
|
||||||
} else {
|
} else {
|
||||||
for(int m=0,n=articleTagDTOList.size()-1;m<n; m++) {
|
|
||||||
ArticleTagDTO articleTag = articleTagDTOList.get(m);
|
|
||||||
if (articleTag.getIdTag().equals(tag.getIdTag())) {
|
|
||||||
articleTagDTOList.remove(articleTag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Integer count = tagMapper.selectCountTagArticleById(tag.getIdTag(),article.getIdArticle());
|
Integer count = tagMapper.selectCountTagArticleById(tag.getIdTag(),article.getIdArticle());
|
||||||
if(count == 0){
|
if(count == 0){
|
||||||
tag.setTagArticleCount(tag.getTagArticleCount() + 1);
|
tag.setTagArticleCount(tag.getTagArticleCount() + 1);
|
||||||
@ -76,9 +65,6 @@ public class TagServiceImpl extends AbstractService<Tag> implements TagService {
|
|||||||
addUserTag = true;
|
addUserTag = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
articleTagDTOList.forEach(articleTagDTO -> {
|
|
||||||
articleMapper.deleteUnusedArticleTag(articleTagDTO.getIdArticleTag());
|
|
||||||
});
|
|
||||||
if(addTagArticle){
|
if(addTagArticle){
|
||||||
tagMapper.insertTagArticle(tag.getIdTag(),article.getIdArticle());
|
tagMapper.insertTagArticle(tag.getIdTag(),article.getIdArticle());
|
||||||
}
|
}
|
||||||
|
@ -33,29 +33,6 @@ public class BaiDuUtils {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
},executor);
|
},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<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);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateSEOData(String permalink) {
|
public static void updateSEOData(String permalink) {
|
||||||
@ -100,7 +77,7 @@ public class BaiDuUtils {
|
|||||||
},executor);
|
},executor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(){
|
public static void main(String agrs[]){
|
||||||
sendUpdateSEOData("https://rymcu.com");
|
sendSEOData("https://rymcu.com/article/31");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class NotificationUtils {
|
|||||||
},executor);
|
},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<Runnable>());
|
ExecutorService executor= new ThreadPoolExecutor(1,1,0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
|
||||||
CompletableFuture.supplyAsync(()-> {
|
CompletableFuture.supplyAsync(()-> {
|
||||||
try {
|
try {
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
package com.rymcu.vertical.web.api.article;
|
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.GlobalResult;
|
||||||
import com.rymcu.vertical.core.result.GlobalResultGenerator;
|
import com.rymcu.vertical.core.result.GlobalResultGenerator;
|
||||||
import com.rymcu.vertical.dto.ArticleDTO;
|
import com.rymcu.vertical.dto.ArticleDTO;
|
||||||
import com.rymcu.vertical.dto.CommentDTO;
|
|
||||||
import com.rymcu.vertical.service.ArticleService;
|
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 com.rymcu.vertical.web.api.exception.BaseApiException;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -16,7 +11,6 @@ import javax.annotation.Resource;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,8 +22,6 @@ public class ArticleController {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ArticleService articleService;
|
private ArticleService articleService;
|
||||||
@Resource
|
|
||||||
private CommentService commentService;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -59,27 +51,4 @@ public class ArticleController {
|
|||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{id}/comments")
|
|
||||||
public GlobalResult<Map<String, Object>> commons(@PathVariable Integer id){
|
|
||||||
List<CommentDTO> 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<ArticleDTO> list = articleService.findDrafts();
|
|
||||||
PageInfo<ArticleDTO> 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -35,7 +35,6 @@
|
|||||||
<result column="time_ago" property="timeAgo"></result>
|
<result column="time_ago" property="timeAgo"></result>
|
||||||
<result column="article_permalink" property="articlePermalink"></result>
|
<result column="article_permalink" property="articlePermalink"></result>
|
||||||
<result column="article_link" property="articleLink"></result>
|
<result column="article_link" property="articleLink"></result>
|
||||||
<result column="article_status" property="articleStatus"></result>
|
|
||||||
<result column="updated_time" property="updatedTime"></result>
|
<result column="updated_time" property="updatedTime"></result>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<resultMap id="AuthorResultMap" type="com.rymcu.vertical.dto.Author">
|
<resultMap id="AuthorResultMap" type="com.rymcu.vertical.dto.Author">
|
||||||
@ -51,13 +50,11 @@
|
|||||||
<result column="updated_time" property="updatedTime"/>
|
<result column="updated_time" property="updatedTime"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<resultMap id="ArticleTagDTOResultMap" type="com.rymcu.vertical.dto.ArticleTagDTO">
|
<resultMap id="ArticleTagDTOResultMap" type="com.rymcu.vertical.dto.ArticleTagDTO">
|
||||||
<id column="id" property="idArticleTag"/>
|
<id column="id" property="idTag"/>
|
||||||
<result column="id_tag" property="idTag"></result>
|
<id column="tag_title" property="tagTitle"/>
|
||||||
<result column="id_article" property="idArticle"></result>
|
<id column="tag_icon_path" property="tagIconPath"/>
|
||||||
<result column="tag_title" property="tagTitle"></result>
|
<id column="tag_uri" property="tagUri"/>
|
||||||
<result column="tag_icon_path" property="tagIconPath"></result>
|
<id column="tag_description" property="tagDescription"/>
|
||||||
<result column="tag_uri" property="tagUri"></result>
|
|
||||||
<result column="tag_description" property="tagDescription"></result>
|
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<insert id="insertArticleContent">
|
<insert id="insertArticleContent">
|
||||||
insert into vertical_article_content (id_article,article_content,article_content_html,created_time,updated_time)
|
insert into vertical_article_content (id_article,article_content,article_content_html,created_time,updated_time)
|
||||||
@ -72,20 +69,14 @@
|
|||||||
<delete id="deleteTagArticle">
|
<delete id="deleteTagArticle">
|
||||||
delete from vertical_tag_article where id_article = #{id}
|
delete from vertical_tag_article where id_article = #{id}
|
||||||
</delete>
|
</delete>
|
||||||
<delete id="deleteUnusedArticleTag">
|
|
||||||
delete from vertical_tag_article where id = #{idArticleTag}
|
|
||||||
</delete>
|
|
||||||
<select id="selectArticles" resultMap="DTOResultMap">
|
<select id="selectArticles" resultMap="DTOResultMap">
|
||||||
select art.*,su.nickname,su.avatar_url from vertical_article art left join vertical_user su on art.article_author_id = su.id where article_status = '0' order by updated_time desc
|
select art.*,su.nickname,su.avatar_url from vertical_article art left join vertical_user su on art.article_author_id = su.id order by updated_time desc
|
||||||
</select>
|
</select>
|
||||||
<select id="selectAuthor" resultMap="AuthorResultMap">
|
<select id="selectAuthor" resultMap="AuthorResultMap">
|
||||||
select * from vertical_user where id = #{id}
|
select * from vertical_user where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
<select id="selectArticleDTOById" resultMap="DTOResultMap">
|
<select id="selectArticleDTOById" resultMap="DTOResultMap">
|
||||||
select art.*,su.nickname,su.avatar_url from vertical_article art left join vertical_user su on art.article_author_id = su.id where art.id = #{id}
|
select art.*,su.nickname,su.avatar_url from vertical_article art left join vertical_user su on art.article_author_id = su.id where art.id = #{id}
|
||||||
<if test="type == 1">
|
|
||||||
and art.article_status = 0
|
|
||||||
</if>
|
|
||||||
</select>
|
</select>
|
||||||
<select id="selectArticleContent" resultMap="ArticleContentResultMap">
|
<select id="selectArticleContent" resultMap="ArticleContentResultMap">
|
||||||
select article_content,article_content_html from vertical_article_content where id_article = #{idArticle}
|
select article_content,article_content_html from vertical_article_content where id_article = #{idArticle}
|
||||||
@ -103,9 +94,6 @@
|
|||||||
select art.*,su.nickname,su.avatar_url from vertical_article art left join vertical_user su on su.id = #{idUser} and art.article_author_id = su.id where article_author_id = #{idUser} order by updated_time desc
|
select art.*,su.nickname,su.avatar_url from vertical_article art left join vertical_user su on su.id = #{idUser} and art.article_author_id = su.id where article_author_id = #{idUser} order by updated_time desc
|
||||||
</select>
|
</select>
|
||||||
<select id="selectTags" resultMap="ArticleTagDTOResultMap">
|
<select id="selectTags" resultMap="ArticleTagDTOResultMap">
|
||||||
select vta.id, vta.id_tag, vta.id_article, vt.tag_title, vt.tag_icon_path, vt.tag_uri, vt.tag_description from vertical_tag vt left join vertical_tag_article vta on vt.id = vta.id_tag where vta.id_article = #{idArticle}
|
select vt.id, vt.tag_title, vt.tag_icon_path, vt.tag_uri, vt.tag_description from vertical_tag vt left join vertical_tag_article vta on vt.id = vta.id_tag where vta.id_article = #{idArticle}
|
||||||
</select>
|
|
||||||
<select id="selectDrafts" resultMap="DTOResultMap">
|
|
||||||
select art.*,su.nickname,su.avatar_url from vertical_article art left join vertical_user su on art.article_author_id = su.id where article_status = '1' and art.article_author_id = #{idUser} order by updated_time desc
|
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
@ -1,49 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
|
||||||
<mapper namespace="com.rymcu.vertical.mapper.CommentMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.rymcu.vertical.entity.Comment">
|
|
||||||
<id column="id" property="idComment"></id>
|
|
||||||
<result column="comment_content" property="commentContent"></result>
|
|
||||||
<result column="comment_author_id" property="commentAuthorId"></result>
|
|
||||||
<result column="comment_article_id" property="commentArticleId"></result>
|
|
||||||
<result column="comment_sharp_url" property="commentSharpUrl"></result>
|
|
||||||
<result column="comment_original_comment_id" property="commentOriginalCommentId"></result>
|
|
||||||
<result column="comment_status" property="commentStatus"></result>
|
|
||||||
<result column="comment_ip" property="commentIP"></result>
|
|
||||||
<result column="comment_ua" property="commentUA"></result>
|
|
||||||
<result column="comment_anonymous" property="commentAnonymous"></result>
|
|
||||||
<result column="comment_reply_count" property="commentReplyCount"></result>
|
|
||||||
<result column="comment_visible" property="commentVisible"></result>
|
|
||||||
<result column="created_time" property="createdTime"></result>
|
|
||||||
</resultMap>
|
|
||||||
<resultMap id="DTOResultMap" type="com.rymcu.vertical.dto.CommentDTO">
|
|
||||||
<id column="id" property="idComment"></id>
|
|
||||||
<result column="comment_content" property="commentContent"></result>
|
|
||||||
<result column="comment_author_id" property="commentAuthorId"></result>
|
|
||||||
<result column="comment_article_id" property="commentArticleId"></result>
|
|
||||||
<result column="comment_sharp_url" property="commentSharpUrl"></result>
|
|
||||||
<result column="comment_original_comment_id" property="commentOriginalCommentId"></result>
|
|
||||||
<result column="comment_status" property="commentStatus"></result>
|
|
||||||
<result column="comment_anonymous" property="commentAnonymous"></result>
|
|
||||||
<result column="comment_reply_count" property="commentReplyCount"></result>
|
|
||||||
<result column="comment_visible" property="commentVisible"></result>
|
|
||||||
<result column="created_time" property="createdTime"></result>
|
|
||||||
</resultMap>
|
|
||||||
<resultMap id="AuthorResultMap" type="com.rymcu.vertical.dto.Author">
|
|
||||||
<result column="id" property="idUser"/>
|
|
||||||
<result column="nickname" property="userNickname"/>
|
|
||||||
<result column="avatar_url" property="userAvatarURL"/>
|
|
||||||
</resultMap>
|
|
||||||
<update id="updateCommentSharpUrl">
|
|
||||||
update vertical_comment set comment_sharp_url = #{commentSharpUrl} where id = #{idComment}
|
|
||||||
</update>
|
|
||||||
<select id="selectArticleComments" resultMap="DTOResultMap">
|
|
||||||
select * from vertical_comment where comment_article_id = #{idArticle} order by created_time desc
|
|
||||||
</select>
|
|
||||||
<select id="selectAuthor" resultMap="AuthorResultMap">
|
|
||||||
select id,nickname,avatar_url from vertical_user where id = #{commentAuthorId}
|
|
||||||
</select>
|
|
||||||
<select id="selectCommentOriginalAuthor" resultMap="AuthorResultMap">
|
|
||||||
select vu.id,vu.nickname,vu.avatar_url from vertical_comment vc left join vertical_user vu on vu.id = vc.comment_author_id where vc.id = #{commentOriginalCommentId}
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
@ -17,7 +17,7 @@
|
|||||||
update vertical_role set status = #{status},updated_time = sysdate() where id = #{idRole}
|
update vertical_role set status = #{status},updated_time = sysdate() where id = #{idRole}
|
||||||
</update>
|
</update>
|
||||||
<update id="update">
|
<update id="update">
|
||||||
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}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<select id="selectRoleByIdUser" resultMap="BaseResultMap">
|
<select id="selectRoleByIdUser" resultMap="BaseResultMap">
|
||||||
|
Loading…
Reference in New Issue
Block a user