Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
T
tanpu-community
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
探普后端
tanpu-community
Commits
0936157e
Commit
0936157e
authored
Aug 27, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步评论转发,评论点赞消息通知
parent
0c953467
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
19 deletions
+11
-19
CommentManager.java
...main/java/com/tanpu/community/manager/CommentManager.java
+11
-1
CollectionService.java
...n/java/com/tanpu/community/service/CollectionService.java
+0
-18
No files found.
community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
View file @
0936157e
...
...
@@ -29,6 +29,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Set
;
...
...
@@ -71,6 +72,7 @@ public class CommentManager {
throw
new
IllegalArgumentException
(
"评论内容不能超过500字"
);
}
LocalDateTime
now
=
LocalDateTime
.
now
();
CommentEntity
commentEntity
=
CommentEntity
.
builder
()
.
themeId
(
req
.
getThemeId
())
.
parentId
(
req
.
getParentId
())
...
...
@@ -78,6 +80,8 @@ public class CommentManager {
.
authorId
(
userId
)
.
content
(
req
.
getComment
())
.
commentType
(
CommentTypeEnum
.
THEME
.
getCode
())
.
createTime
(
now
)
.
updateTime
(
now
)
.
build
();
commentService
.
insertComment
(
commentEntity
);
...
...
@@ -155,7 +159,13 @@ public class CommentManager {
//点赞评论/取消点赞
public
void
likeComment
(
LikeCommentReq
req
,
String
userId
)
{
if
(
OperationTypeEnum
.
CONFIRM
.
getCode
().
equals
(
req
.
getType
()))
{
collectionService
.
saveOrUpdate
(
req
.
getCommentId
(),
userId
,
CollectionTypeEnum
.
LIKE_COMMENT
);
boolean
b
=
collectionService
.
saveOrUpdate
(
req
.
getCommentId
(),
userId
,
CollectionTypeEnum
.
LIKE_COMMENT
);
if
(
b
){
CommentEntity
commentEntity
=
commentService
.
queryByCommentId
(
req
.
getCommentId
());
ThemeEntity
themeEntity
=
themeService
.
queryByThemeId
(
commentEntity
.
getThemeId
());
notificationService
.
insert
(
userId
,
commentEntity
.
getAuthorId
(),
NotificationTypeEnum
.
COMMENT_LIKE
,
themeEntity
.
getThemeId
(),
req
.
getCommentId
());
notificationService
.
putNotifyCache
(
commentEntity
.
getAuthorId
(),
userId
,
NotificationTypeEnum
.
COMMENT_LIKE
);
}
}
else
if
(
OperationTypeEnum
.
CANCEL
.
getCode
().
equals
(
req
.
getType
()))
{
collectionService
.
delete
(
req
.
getCommentId
(),
userId
,
CollectionTypeEnum
.
LIKE_COMMENT
);
...
...
community-service/src/main/java/com/tanpu/community/service/CollectionService.java
View file @
0936157e
...
...
@@ -3,15 +3,11 @@ package com.tanpu.community.service;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.tanpu.biz.common.enums.community.CollectionTypeEnum
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.NotificationTypeEnum
;
import
com.tanpu.community.dao.entity.community.CollectionEntity
;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.dao.entity.community.TimesCountEntity
;
import
com.tanpu.community.dao.mapper.community.CollectionMapper
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -30,14 +26,6 @@ public class CollectionService {
@Resource
private
CollectionMapper
collectionMapper
;
@Autowired
private
NotificationService
notificationService
;
@Autowired
private
ThemeService
themeService
;
@Autowired
private
CommentService
commentService
;
// 若不存在则新增,若存在则修改deleteTag
...
...
@@ -64,12 +52,6 @@ public class CollectionService {
collectionMapper
.
insert
(
entity
);
CommentEntity
commentEntity
=
commentService
.
queryByCommentId
(
targetId
);
ThemeEntity
themeEntity
=
themeService
.
queryByThemeId
(
commentEntity
.
getThemeId
());
notificationService
.
insert
(
userId
,
themeEntity
.
getAuthorId
(),
NotificationTypeEnum
.
COMMENT_LIKE
,
themeEntity
.
getThemeId
(),
targetId
);
notificationService
.
putNotifyCache
(
themeEntity
.
getAuthorId
(),
userId
,
NotificationTypeEnum
.
COMMENT_LIKE
);
return
true
;
}
}
...
...
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