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
0cf557e3
Commit
0cf557e3
authored
Aug 19, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除评论时删除消息通知
parent
49ed72df
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
20 deletions
+17
-20
CommentManager.java
...main/java/com/tanpu/community/manager/CommentManager.java
+1
-2
NotificationService.java
...java/com/tanpu/community/service/NotificationService.java
+16
-18
No files found.
community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
View file @
0cf557e3
...
@@ -169,11 +169,10 @@ public class CommentManager {
...
@@ -169,11 +169,10 @@ public class CommentManager {
//删除评论
//删除评论
public
void
delete
(
String
commentId
,
String
userId
)
{
public
void
delete
(
String
commentId
,
String
userId
)
{
commentService
.
delete
(
commentId
,
userId
);
commentService
.
delete
(
commentId
,
userId
);
notificationService
.
deleteComment
(
commentId
);
CommentEntity
commentEntity
=
commentService
.
queryByIdIncludeDelete
(
commentId
);
CommentEntity
commentEntity
=
commentService
.
queryByIdIncludeDelete
(
commentId
);
ThemeEntity
themeEntity
=
themeService
.
queryByThemeId
(
commentEntity
.
getThemeId
());
ThemeEntity
themeEntity
=
themeService
.
queryByThemeId
(
commentEntity
.
getThemeId
());
notificationService
.
delete
NotifyCache
(
themeEntity
.
getAuthorId
(),
userId
,
commentId
,
commentEntity
.
getCreateTime
());
notificationService
.
delete
CommentNotify
(
themeEntity
.
getAuthorId
(),
userId
,
commentId
,
commentEntity
.
getCreateTime
());
}
}
...
...
community-service/src/main/java/com/tanpu/community/service/NotificationService.java
View file @
0cf557e3
...
@@ -195,15 +195,10 @@ public class NotificationService {
...
@@ -195,15 +195,10 @@ public class NotificationService {
redisCache
.
set
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_TIME
+
notifyUserId
,
TimeUtils
.
format
(
LocalDateTime
.
now
()),
60
*
60
*
24
*
30
);
redisCache
.
set
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_TIME
+
notifyUserId
,
TimeUtils
.
format
(
LocalDateTime
.
now
()),
60
*
60
*
24
*
30
);
}
}
private
UserInfoResp
getUserInfo
(
String
authorId
)
{
CommonResp
<
UserInfoResp
>
userInfoNewCommonResp
=
feignClientForFatools
.
queryUserInfoNew
(
authorId
);
if
(
userInfoNewCommonResp
.
isNotSuccess
())
{
throw
new
BizException
(
"内部接口调用失败"
);
}
return
userInfoNewCommonResp
.
getData
();
}
public
void
deleteNotifyCache
(
String
notifyUserId
,
String
operatorId
,
String
commentId
,
LocalDateTime
commentTime
)
{
// 删除评论及缓存
public
void
deleteCommentNotify
(
String
notifyUserId
,
String
operatorId
,
String
commentId
,
LocalDateTime
commentTime
)
{
// 物理删除
// 物理删除
NotificationEntity
commentNotify
=
notificationMapper
.
selectOne
(
new
LambdaQueryWrapper
<
NotificationEntity
>().
eq
(
NotificationEntity:
:
getTargetId
,
commentId
));
NotificationEntity
commentNotify
=
notificationMapper
.
selectOne
(
new
LambdaQueryWrapper
<
NotificationEntity
>().
eq
(
NotificationEntity:
:
getTargetId
,
commentId
));
NotificationEntity
last
=
notificationMapper
.
selectOne
(
new
LambdaQueryWrapper
<
NotificationEntity
>().
eq
(
NotificationEntity:
:
getNotifiedUserId
,
notifyUserId
)
NotificationEntity
last
=
notificationMapper
.
selectOne
(
new
LambdaQueryWrapper
<
NotificationEntity
>().
eq
(
NotificationEntity:
:
getNotifiedUserId
,
notifyUserId
)
...
@@ -216,10 +211,12 @@ public class NotificationService {
...
@@ -216,10 +211,12 @@ public class NotificationService {
.
orderByDesc
(
NotificationEntity:
:
getUpdateTime
)
.
orderByDesc
(
NotificationEntity:
:
getUpdateTime
)
.
last
(
"limit 1"
));
.
last
(
"limit 1"
));
if
(
last
==
null
)
{
if
(
last
==
null
)
{
// 没有其他通知,置空
redisCache
.
evict
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_MSG
+
notifyUserId
);
redisCache
.
evict
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_MSG
+
notifyUserId
);
redisCache
.
evict
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_TIME
+
notifyUserId
);
redisCache
.
evict
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_TIME
+
notifyUserId
);
}
else
{
}
else
{
// 有通知
UserInfoResp
userInfo
=
getUserInfo
(
last
.
getOperatorId
());
UserInfoResp
userInfo
=
getUserInfo
(
last
.
getOperatorId
());
redisCache
.
set
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_TIME
+
notifyUserId
,
TimeUtils
.
format
(
last
.
getUpdateTime
()),
60
*
60
*
24
*
30
);
redisCache
.
set
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_TIME
+
notifyUserId
,
TimeUtils
.
format
(
last
.
getUpdateTime
()),
60
*
60
*
24
*
30
);
if
(
NotificationTypeEnum
.
FOLLOW
.
getCode
().
equals
(
last
.
getMessageType
()))
{
if
(
NotificationTypeEnum
.
FOLLOW
.
getCode
().
equals
(
last
.
getMessageType
()))
{
...
@@ -228,22 +225,16 @@ public class NotificationService {
...
@@ -228,22 +225,16 @@ public class NotificationService {
redisCache
.
set
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_MSG
+
notifyUserId
redisCache
.
set
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_MSG
+
notifyUserId
,
userInfo
.
getNickName
()
+
NotificationTypeEnum
.
lookup
(
last
.
getMessageType
())
+
"了你的内容"
,
userInfo
.
getNickName
()
+
NotificationTypeEnum
.
lookup
(
last
.
getMessageType
())
+
"了你的内容"
,
60
*
60
*
24
*
30
);
,
60
*
60
*
24
*
30
);
}
}
}
}
}
}
// 处理更新数量
LocalDateTime
lastQueryTime
=
TimeUtils
.
reFormat
(
redisCache
.
get
(
RedisKeyConstant
.
MESSAGE_NOTIFY_QUERY_TIME
+
notifyUserId
));
String
lastQueryTime
=
redisCache
.
get
(
RedisKeyConstant
.
MESSAGE_NOTIFY_QUERY_TIME
+
notifyUserId
);
// 如果删除的评论时时间在红点提示时间内,则需要加工缓存
// 如果删除的评论时时间在红点提示时间内,则缓存数-1
if
(
TimeUtils
.
lessThan
(
lastQueryTime
,
commentTime
))
{
if
(!
TimeUtils
.
lessThan
(
lastQueryTime
,
commentTime
))
{
UserInfoResp
userInfo
=
getUserInfo
(
operatorId
);
// 红点数-1
redisCache
.
decr
(
RedisKeyConstant
.
MESSAGE_NOTIFY_COUNT
+
notifyUserId
);
redisCache
.
decr
(
RedisKeyConstant
.
MESSAGE_NOTIFY_COUNT
+
notifyUserId
);
}
}
}
}
...
@@ -275,4 +266,11 @@ public class NotificationService {
...
@@ -275,4 +266,11 @@ public class NotificationService {
}
}
private
UserInfoResp
getUserInfo
(
String
authorId
)
{
CommonResp
<
UserInfoResp
>
userInfoNewCommonResp
=
feignClientForFatools
.
queryUserInfoNew
(
authorId
);
if
(
userInfoNewCommonResp
.
isNotSuccess
())
{
throw
new
BizException
(
"内部接口调用失败"
);
}
return
userInfoNewCommonResp
.
getData
();
}
}
}
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