Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beyond-clouds
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
段启岩
beyond-clouds
Commits
2ac2f944
Commit
2ac2f944
authored
Feb 16, 2020
by
段启岩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
消息类型增加
parent
f259d7ac
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
87 additions
and
21 deletions
+87
-21
src/main/java/cn/meteor/beyondclouds/modules/blog/service/impl/BlogCommentServiceImpl.java
+14
-0
src/main/java/cn/meteor/beyondclouds/modules/message/listener/MessageListener.java
+43
-19
src/main/java/cn/meteor/beyondclouds/modules/post/service/impl/PostCommentServiceImpl.java
+13
-0
src/main/java/cn/meteor/beyondclouds/modules/project/api/ProjectCommentApi.java
+3
-2
src/main/java/cn/meteor/beyondclouds/modules/project/service/impl/ProjectCommentServiceImpl.java
+14
-0
No files found.
src/main/java/cn/meteor/beyondclouds/modules/blog/service/impl/BlogCommentServiceImpl.java
View file @
2ac2f944
package
cn
.
meteor
.
beyondclouds
.
modules
.
blog
.
service
.
impl
;
import
cn.meteor.beyondclouds.core.queue.message.DataItemChangeMessage
;
import
cn.meteor.beyondclouds.core.queue.message.DataItemType
;
import
cn.meteor.beyondclouds.modules.blog.entity.Blog
;
import
cn.meteor.beyondclouds.modules.blog.entity.BlogComment
;
import
cn.meteor.beyondclouds.modules.blog.enums.BlogCommentErrorCode
;
...
...
@@ -9,6 +11,7 @@ import cn.meteor.beyondclouds.modules.blog.exception.BlogServiceException;
import
cn.meteor.beyondclouds.modules.blog.mapper.BlogCommentMapper
;
import
cn.meteor.beyondclouds.modules.blog.service.IBlogCommentService
;
import
cn.meteor.beyondclouds.modules.blog.service.IBlogService
;
import
cn.meteor.beyondclouds.modules.queue.service.IMessageQueueService
;
import
cn.meteor.beyondclouds.modules.user.entity.User
;
import
cn.meteor.beyondclouds.modules.user.service.IUserService
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
...
...
@@ -35,6 +38,8 @@ public class BlogCommentServiceImpl extends ServiceImpl<BlogCommentMapper, BlogC
private
IUserService
userService
;
private
IMessageQueueService
messageQueueService
;
@Autowired
public
void
setBlogService
(
IBlogService
blogService
)
{
this
.
blogService
=
blogService
;
...
...
@@ -45,6 +50,12 @@ public class BlogCommentServiceImpl extends ServiceImpl<BlogCommentMapper, BlogC
this
.
userService
=
userService
;
}
@Autowired
public
void
setMessageQueueService
(
IMessageQueueService
messageQueueService
)
{
this
.
messageQueueService
=
messageQueueService
;
}
/**
* 发布评论
* @param blogId
...
...
@@ -119,6 +130,9 @@ public class BlogCommentServiceImpl extends ServiceImpl<BlogCommentMapper, BlogC
blogComment
.
setThread
(
thread
);
//5.更新路径信息
updateById
(
blogComment
);
messageQueueService
.
sendDataItemChangeMessage
(
DataItemChangeMessage
.
addMessage
(
DataItemType
.
BLOG_COMMENT
,
blogComment
.
getCommentId
(),
userId
));
}
...
...
src/main/java/cn/meteor/beyondclouds/modules/message/listener/MessageListener.java
View file @
2ac2f944
...
...
@@ -17,6 +17,10 @@ import cn.meteor.beyondclouds.modules.project.entity.Project;
import
cn.meteor.beyondclouds.modules.project.entity.ProjectComment
;
import
cn.meteor.beyondclouds.modules.project.service.IProjectCommentService
;
import
cn.meteor.beyondclouds.modules.project.service.IProjectService
;
import
cn.meteor.beyondclouds.modules.question.entity.Question
;
import
cn.meteor.beyondclouds.modules.question.entity.QuestionReply
;
import
cn.meteor.beyondclouds.modules.question.service.IQuestionReplyService
;
import
cn.meteor.beyondclouds.modules.question.service.IQuestionService
;
import
cn.meteor.beyondclouds.modules.user.entity.User
;
import
cn.meteor.beyondclouds.modules.user.entity.UserFollow
;
import
cn.meteor.beyondclouds.modules.user.service.IUserFollowService
;
...
...
@@ -41,6 +45,9 @@ public class MessageListener implements DataItemChangeListener {
private
IProjectCommentService
projectCommentService
;
private
IPostService
postService
;
private
IPostCommentService
postCommentService
;
private
IQuestionReplyService
questionReplyService
;
private
IQuestionService
questionService
;
@Autowired
public
void
setMessageService
(
IMessageService
messageService
)
{
...
...
@@ -83,6 +90,20 @@ public class MessageListener implements DataItemChangeListener {
}
@Autowired
public
void
setQuestionReplyService
(
IQuestionReplyService
questionReplyService
)
{
this
.
questionReplyService
=
questionReplyService
;
}
@Override
public
void
onUserAvatarUpdate
(
DataItemChangeMessage
dataItemChangeMessage
)
{
}
public
void
setQuestionService
(
IQuestionService
questionService
)
{
this
.
questionService
=
questionService
;
}
@Autowired
public
void
setUserService
(
IUserService
userService
)
{
this
.
userService
=
userService
;
}
...
...
@@ -197,32 +218,35 @@ public class MessageListener implements DataItemChangeListener {
}
// 问题
if
(
itemType
.
equals
(
DataItemType
.
PROJECT_COMMENT
))
{
if
(
itemType
.
equals
(
DataItemType
.
QUESTION_REPLY
))
{
// 获取
评论
PostComment
comment
=
postComment
Service
.
getById
(
itemId
);
// 获取
回答
QuestionReply
questionReply
=
questionReply
Service
.
getById
(
itemId
);
// 获取父评论
PostComment
parentComment
=
null
;
if
(
comment
.
getParentId
()
!=
null
)
{
parentComment
=
postCommentService
.
getById
(
parentComment
.
getParentId
());
}
// 获取问题
Question
question
=
questionService
.
getById
(
questionReply
.
getQuestionId
());
// 获取博客
Post
post
=
postService
.
getById
(
comment
.
getPostId
());
// 给问题提出者发消息
Message
messageToAuthor
=
new
Message
();
messageToAuthor
.
setUserId
(
question
.
getUserId
());
messageToAuthor
.
setMscContent
(
String
.
format
(
"用户%s对您的问题%s进行了回答!"
,
questionReply
.
getUserNick
(),
question
.
getQuestionTitle
()));
messageService
.
save
(
messageToAuthor
);
}
// 回答采纳
if
(
itemType
.
equals
(
DataItemType
.
QUESTION_REPLY_ACCEPT
))
{
// 给博主发消息
// 获取回答
QuestionReply
questionReply
=
questionReplyService
.
getById
(
itemId
);
// 获取问题
Question
question
=
questionService
.
getById
(
questionReply
.
getQuestionId
());
// 给问题提出者发消息
Message
messageToAuthor
=
new
Message
();
messageToAuthor
.
setUserId
(
post
.
getUserId
());
messageToAuthor
.
setMscContent
(
String
.
format
(
"
用户%s对您的动态%s进行了评论!"
,
comment
.
getUserNick
(),
post
.
getContent
()));
messageToAuthor
.
setUserId
(
questionReply
.
getUserId
());
messageToAuthor
.
setMscContent
(
String
.
format
(
"
您在问题%s的回答被采纳了!"
,
question
.
getQuestionTitle
()));
messageService
.
save
(
messageToAuthor
);
// 给父评论的用户发消息
if
(
null
!=
parentComment
)
{
Message
messageToParentCommenter
=
new
Message
();
messageToParentCommenter
.
setUserId
(
parentComment
.
getUserId
());
messageToParentCommenter
.
setMscContent
(
String
.
format
(
"用户%s对您在动态%s下的评论进行了回复"
,
comment
.
getUserNick
(),
post
.
getContent
()));
}
}
...
...
src/main/java/cn/meteor/beyondclouds/modules/post/service/impl/PostCommentServiceImpl.java
View file @
2ac2f944
package
cn
.
meteor
.
beyondclouds
.
modules
.
post
.
service
.
impl
;
import
cn.meteor.beyondclouds.core.queue.message.DataItemChangeMessage
;
import
cn.meteor.beyondclouds.core.queue.message.DataItemType
;
import
cn.meteor.beyondclouds.modules.post.entity.Post
;
import
cn.meteor.beyondclouds.modules.post.entity.PostComment
;
import
cn.meteor.beyondclouds.modules.post.enums.PostCommentErrorCode
;
...
...
@@ -9,6 +11,7 @@ import cn.meteor.beyondclouds.modules.post.exception.PostServiceException;
import
cn.meteor.beyondclouds.modules.post.mapper.PostCommentMapper
;
import
cn.meteor.beyondclouds.modules.post.service.IPostCommentService
;
import
cn.meteor.beyondclouds.modules.post.service.IPostService
;
import
cn.meteor.beyondclouds.modules.queue.service.IMessageQueueService
;
import
cn.meteor.beyondclouds.modules.user.entity.User
;
import
cn.meteor.beyondclouds.modules.user.service.IUserService
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
...
...
@@ -35,6 +38,8 @@ public class PostCommentServiceImpl extends ServiceImpl<PostCommentMapper, PostC
private
IUserService
userService
;
private
IMessageQueueService
messageQueueService
;
@Autowired
public
void
setPostService
(
IPostService
postService
)
{
this
.
postService
=
postService
;
...
...
@@ -45,6 +50,11 @@ public class PostCommentServiceImpl extends ServiceImpl<PostCommentMapper, PostC
this
.
userService
=
userService
;
}
@Autowired
public
void
setMessageQueueService
(
IMessageQueueService
messageQueueService
)
{
this
.
messageQueueService
=
messageQueueService
;
}
/**
* 发布评论
* @param postId
...
...
@@ -99,6 +109,9 @@ public class PostCommentServiceImpl extends ServiceImpl<PostCommentMapper, PostC
// 更新动态的评论数量
post
.
setCommentNumber
(
post
.
getCommentNumber
()
+
1
);
postService
.
updateById
(
post
);
messageQueueService
.
sendDataItemChangeMessage
(
DataItemChangeMessage
.
addMessage
(
DataItemType
.
POST_COMMENT
,
postComment
.
getCommentId
(),
userId
));
}
/**
...
...
src/main/java/cn/meteor/beyondclouds/modules/project/api/ProjectCommentApi.java
View file @
2ac2f944
...
...
@@ -6,6 +6,8 @@ import cn.meteor.beyondclouds.core.annotation.Anonymous;
import
cn.meteor.beyondclouds.core.annotation.CurrentSubject
;
import
cn.meteor.beyondclouds.core.api.Response
;
import
cn.meteor.beyondclouds.core.authentication.Subject
;
import
cn.meteor.beyondclouds.core.queue.message.DataItemChangeMessage
;
import
cn.meteor.beyondclouds.core.queue.message.DataItemType
;
import
cn.meteor.beyondclouds.modules.project.entity.ProjectComment
;
import
cn.meteor.beyondclouds.modules.project.exception.ProjectCommentServiceException
;
import
cn.meteor.beyondclouds.modules.project.form.ProjectCommentForm
;
...
...
@@ -62,8 +64,7 @@ public class ProjectCommentApi {
e
.
printStackTrace
();
return
Response
.
error
(
e
);
}
}
}
@ApiOperation
(
"删除评论"
)
@DeleteMapping
(
"/project/comment/{commentId}"
)
...
...
src/main/java/cn/meteor/beyondclouds/modules/project/service/impl/ProjectCommentServiceImpl.java
View file @
2ac2f944
package
cn
.
meteor
.
beyondclouds
.
modules
.
project
.
service
.
impl
;
import
cn.meteor.beyondclouds.core.queue.message.DataItemChangeMessage
;
import
cn.meteor.beyondclouds.core.queue.message.DataItemType
;
import
cn.meteor.beyondclouds.modules.project.entity.Project
;
import
cn.meteor.beyondclouds.modules.project.entity.ProjectComment
;
import
cn.meteor.beyondclouds.modules.project.enums.ProjectCommentErrorCode
;
...
...
@@ -8,6 +10,7 @@ import cn.meteor.beyondclouds.modules.project.exception.ProjectCommentServiceExc
import
cn.meteor.beyondclouds.modules.project.mapper.ProjectCommentMapper
;
import
cn.meteor.beyondclouds.modules.project.service.IProjectCommentService
;
import
cn.meteor.beyondclouds.modules.project.service.IProjectService
;
import
cn.meteor.beyondclouds.modules.queue.service.IMessageQueueService
;
import
cn.meteor.beyondclouds.modules.user.entity.User
;
import
cn.meteor.beyondclouds.modules.user.enums.AuthenticationErrorCode
;
import
cn.meteor.beyondclouds.modules.user.exception.UserServiceException
;
...
...
@@ -36,6 +39,8 @@ public class ProjectCommentServiceImpl extends ServiceImpl<ProjectCommentMapper,
private
IUserService
userService
;
private
IMessageQueueService
messageQueueService
;
@Autowired
public
void
setProjectService
(
IProjectService
projectService
)
{
this
.
projectService
=
projectService
;
...
...
@@ -46,6 +51,11 @@ public class ProjectCommentServiceImpl extends ServiceImpl<ProjectCommentMapper,
this
.
userService
=
userService
;
}
@Autowired
public
void
setMessageQueueService
(
IMessageQueueService
messageQueueService
)
{
this
.
messageQueueService
=
messageQueueService
;
}
@Override
public
void
publishComment
(
Integer
projectId
,
Integer
parentId
,
String
comment
,
String
userId
)
throws
ProjectCommentServiceException
{
Assert
.
notNull
(
projectId
,
"projectId must not be null"
);
...
...
@@ -100,6 +110,10 @@ public class ProjectCommentServiceImpl extends ServiceImpl<ProjectCommentMapper,
projectComment
.
setThread
(
parentComment
.
getThread
()
+
"/"
+
projectComment
.
getCommentId
());
}
updateById
(
projectComment
);
messageQueueService
.
sendDataItemChangeMessage
(
DataItemChangeMessage
.
addMessage
(
DataItemType
.
PROJECT_COMMENT
,
projectComment
.
getCommentId
(),
userId
));
}
@Override
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment