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
d7e1cadc
Commit
d7e1cadc
authored
Feb 23, 2022
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
回复评论推送
parent
dba5d746
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
45 additions
and
5 deletions
+45
-5
NotificationTypeEnum.java
...a/com/tanpu/community/api/enums/NotificationTypeEnum.java
+1
-0
CommentManager.java
...main/java/com/tanpu/community/manager/CommentManager.java
+8
-0
NotificationManager.java
...java/com/tanpu/community/manager/NotificationManager.java
+2
-1
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+3
-0
NotificationService.java
...java/com/tanpu/community/service/NotificationService.java
+2
-0
ThemeService.java
...c/main/java/com/tanpu/community/service/ThemeService.java
+27
-3
ConvertUtil.java
...e/src/main/java/com/tanpu/community/util/ConvertUtil.java
+2
-1
No files found.
community-api/src/main/java/com/tanpu/community/api/enums/NotificationTypeEnum.java
View file @
d7e1cadc
...
...
@@ -13,6 +13,7 @@ public enum NotificationTypeEnum {
COMMENT
(
3
,
"评论"
),
FOLLOW
(
4
,
"关注"
),
COMMENT_LIKE
(
5
,
"点赞评论"
),
COMMENT_REPLY
(
6
,
"回复评论"
),
ALL
(
0
,
"全部"
);
private
Integer
code
;
...
...
community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
View file @
d7e1cadc
...
...
@@ -104,6 +104,14 @@ public class CommentManager {
notificationService
.
insert
(
userId
,
themeEntity
.
getAuthorId
(),
NotificationTypeEnum
.
COMMENT
,
commentEntity
.
getCommentId
(),
req
.
getComment
());
notificationService
.
putNotifyCache
(
themeEntity
.
getAuthorId
(),
userId
,
NotificationTypeEnum
.
COMMENT
);
// 回复提醒
if
(
StringUtils
.
isNotBlank
(
req
.
getReplyId
())){
notificationService
.
insert
(
userId
,
themeEntity
.
getAuthorId
(),
NotificationTypeEnum
.
COMMENT_REPLY
,
commentEntity
.
getReplyId
(),
req
.
getComment
());
notificationService
.
putNotifyCache
(
themeEntity
.
getAuthorId
(),
userId
,
NotificationTypeEnum
.
COMMENT_REPLY
);
}
// 评论同步转发并消息通知
if
(
req
.
getSyncForward
()
==
BizConstant
.
SyncForwardType
.
SYNC_FORWARD
)
{
String
themeId
=
themeService
.
commentSyncForward
(
req
,
userId
);
...
...
community-service/src/main/java/com/tanpu/community/manager/NotificationManager.java
View file @
d7e1cadc
...
...
@@ -96,7 +96,8 @@ public class NotificationManager {
// 评论根据commentEntity找到ThemeId
if
(
NotificationTypeEnum
.
COMMENT
.
getCode
().
equals
(
themeNotifyQo
.
getMessageType
())
||
NotificationTypeEnum
.
COMMENT_LIKE
.
getCode
().
equals
(
themeNotifyQo
.
getMessageType
()))
{
NotificationTypeEnum
.
COMMENT_LIKE
.
getCode
().
equals
(
themeNotifyQo
.
getMessageType
())||
NotificationTypeEnum
.
COMMENT_REPLY
.
getCode
().
equals
(
themeNotifyQo
.
getMessageType
()))
{
// 评论类型将commentId替换为themeId
CommentEntity
commentEntity
=
commentService
.
queryByCommentId
(
themeNotifyQo
.
getCommentId
());
if
(
commentEntity
!=
null
)
{
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
d7e1cadc
...
...
@@ -415,6 +415,9 @@ public class ThemeManager {
// 转发主题
public
CreateThemeResp
forward
(
ForwardThemeReq
req
,
String
userId
)
{
// 校验
themeService
.
checkForwardSpecialPermission
(
req
.
getFormerThemeId
());
ThemeEntity
themeEntity
=
ThemeEntity
.
builder
()
.
content
(
JsonUtil
.
toJson
(
req
.
getContent
()))
.
topicId
(
req
.
getTopicId
())
...
...
community-service/src/main/java/com/tanpu/community/service/NotificationService.java
View file @
d7e1cadc
...
...
@@ -220,6 +220,8 @@ public class NotificationService {
redisCache
.
set
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_MSG
+
notifyUserId
,
userInfo
.
getNickName
()
+
"点赞了你的评论"
,
60
*
60
*
24
*
30
);
}
else
if
(
NotificationTypeEnum
.
FOLLOW
.
equals
(
type
))
{
redisCache
.
set
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_MSG
+
notifyUserId
,
userInfo
.
getNickName
()
+
"关注了你"
,
60
*
60
*
24
*
30
);
}
else
if
(
NotificationTypeEnum
.
COMMENT_REPLY
.
equals
(
type
))
{
redisCache
.
set
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_MSG
+
notifyUserId
,
"您有一条评论被回复啦,快去看看吧~"
,
60
*
60
*
24
*
30
);
}
else
{
redisCache
.
set
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_MSG
+
notifyUserId
,
userInfo
.
getNickName
()
+
type
.
getType
()
+
"了你的内容"
,
60
*
60
*
24
*
30
);
}
...
...
community-service/src/main/java/com/tanpu/community/service/ThemeService.java
View file @
d7e1cadc
...
...
@@ -4,8 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.tanpu.biz.common.enums.RelTypeEnum
;
import
com.tanpu.biz.common.enums.community.ReportStatusEnum
;
import
com.tanpu.common.constant.ErrorCodeConstant
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.common.redis.RedisHelper
;
import
com.tanpu.common.util.JsonUtil
;
import
com.tanpu.common.uuid.UuidGenHelper
;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
...
...
@@ -18,8 +18,10 @@ import com.tanpu.community.api.enums.StatusEnum;
import
com.tanpu.community.api.enums.ThemeTypeEnum
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.dao.entity.community.TimesCountEntity
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.dao.entity.community.VisitLogEntity
;
import
com.tanpu.community.dao.mapper.community.ThemeMapper
;
import
com.tanpu.community.dao.mapper.community.TopicMapper
;
import
com.tanpu.community.dao.mapper.community.VisitLogMapper
;
import
com.tanpu.community.util.ConvertUtil
;
import
com.tanpu.community.util.TimeUtils
;
...
...
@@ -29,7 +31,14 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.util.*
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
@Service
...
...
@@ -42,7 +51,7 @@ public class ThemeService {
private
UuidGenHelper
uuidGenHelper
;
@Resource
private
RedisHelper
redisHel
per
;
private
TopicMapper
topicMap
per
;
@Resource
private
VisitLogMapper
visitLogMapper
;
@Resource
...
...
@@ -310,6 +319,8 @@ public class ThemeService {
}
public
String
commentSyncForward
(
CreateCommentReq
req
,
String
userId
)
{
checkForwardSpecialPermission
(
req
.
getThemeId
());
// 评论构造theme content
List
<
ThemeContentReq
>
themeContentReqs
=
Arrays
.
asList
(
ThemeContentReq
.
builder
().
type
(
RelTypeEnum
.
TEXT
.
type
).
value
(
req
.
getComment
()).
build
());
ThemeContentReq
.
builder
().
type
(
RelTypeEnum
.
TEXT
.
type
).
value
(
req
.
getComment
()).
build
();
...
...
@@ -324,6 +335,19 @@ public class ThemeService {
return
themeEntity
.
getThemeId
();
}
/**
* 专属话题不允许转发
*/
public
void
checkForwardSpecialPermission
(
String
themeId
)
{
ThemeEntity
themeEntity
=
queryByThemeId
(
themeId
);
if
(
themeEntity
!=
null
&&
StringUtils
.
isNotBlank
(
themeEntity
.
getTopicId
())){
TopicEntity
topicEntity
=
topicMapper
.
selectOne
(
new
LambdaQueryWrapper
<
TopicEntity
>().
eq
(
TopicEntity:
:
getTopicId
,
themeEntity
.
getTopicId
()));
if
(
topicEntity
!=
null
&&
topicEntity
.
getSpecialPermission
()==
1
){
throw
new
BizException
(
ErrorCodeConstant
.
TOPIC_FORWARD_ABORT
.
getCode
(),
"专属话题不允许转发"
);
}
}
}
public
void
queryCommentForTopic
(
List
<
TopicFollowQo
>
topicQos
,
String
userId
)
{
...
...
community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java
View file @
d7e1cadc
...
...
@@ -301,7 +301,8 @@ public class ConvertUtil {
}
// 评、点赞评论 评论Id
if
(
entity
.
getMessageType
().
equals
(
NotificationTypeEnum
.
COMMENT_LIKE
.
getCode
())
||
entity
.
getMessageType
().
equals
(
NotificationTypeEnum
.
COMMENT
.
getCode
())
entity
.
getMessageType
().
equals
(
NotificationTypeEnum
.
COMMENT
.
getCode
())
||
entity
.
getMessageType
().
equals
(
NotificationTypeEnum
.
COMMENT_REPLY
.
getCode
())
)
{
themeNotifyQo
.
setCommentId
(
entity
.
getTargetId
());
}
...
...
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