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
b551b892
Commit
b551b892
authored
Aug 16, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
消息通知添加themeId
parent
49f1f220
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
62 deletions
+60
-62
NotificationController.java
...om/tanpu/community/controller/NotificationController.java
+1
-1
NotificationManager.java
...java/com/tanpu/community/manager/NotificationManager.java
+7
-7
NotificationService.java
...java/com/tanpu/community/service/NotificationService.java
+43
-20
TopicService.java
...c/main/java/com/tanpu/community/service/TopicService.java
+0
-34
TimeUtils.java
...ice/src/main/java/com/tanpu/community/util/TimeUtils.java
+9
-0
No files found.
community-service/src/main/java/com/tanpu/community/controller/NotificationController.java
View file @
b551b892
...
@@ -63,7 +63,7 @@ public class NotificationController {
...
@@ -63,7 +63,7 @@ public class NotificationController {
if
(!
"admin"
.
equals
(
userHolder
.
getUserId
())){
if
(!
"admin"
.
equals
(
userHolder
.
getUserId
())){
return
CommonResp
.
failed
(
"权限不足"
);
return
CommonResp
.
failed
(
"权限不足"
);
}
}
notificationManager
.
init
();
notificationManager
.
init
AllData
();
return
CommonResp
.
success
();
return
CommonResp
.
success
();
}
}
...
...
community-service/src/main/java/com/tanpu/community/manager/NotificationManager.java
View file @
b551b892
...
@@ -136,25 +136,25 @@ public class NotificationManager {
...
@@ -136,25 +136,25 @@ public class NotificationManager {
}
}
// 查询消息通知概览
public
NotificationQo
queryBriefInfo
(
String
userId
)
{
public
NotificationQo
queryBriefInfo
(
String
userId
)
{
String
count
=
redisCache
.
get
(
RedisKeyConstant
.
MESSAGE_NOTIFY_COUNT
+
userId
);
String
count
=
redisCache
.
get
(
RedisKeyConstant
.
MESSAGE_NOTIFY_COUNT
+
userId
);
String
lastMsg
=
redisCache
.
get
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_MSG
+
userId
);
String
lastMsg
=
redisCache
.
get
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_MSG
+
userId
);
String
lastTime
=
redisCache
.
get
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_TIME
+
userId
);
String
lastTime
=
redisCache
.
get
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_TIME
+
userId
);
return
NotificationQo
.
builder
().
message
(
lastMsg
).
updateCount
(
count
==
null
?
0
:
Integer
.
parseInt
(
count
)).
updateTime
(
lastTime
).
build
();
return
NotificationQo
.
builder
().
message
(
lastMsg
).
updateCount
(
count
==
null
?
0
:
Integer
.
parseInt
(
count
)).
updateTime
(
lastTime
).
build
();
}
}
// 初始化所有消息通知
// 初始化所有消息通知
public
void
init
()
{
public
void
init
AllData
()
{
notificationService
.
truncate
();
notificationService
.
truncate
();
// 关注
// 关注
List
<
FollowRelEntity
>
followRelEntities
=
followRelService
.
queryAll
();
List
<
FollowRelEntity
>
followRelEntities
=
followRelService
.
queryAll
();
for
(
FollowRelEntity
followRelEntity
:
followRelEntities
)
{
for
(
FollowRelEntity
followRelEntity
:
followRelEntities
)
{
notificationService
.
insert
(
followRelEntity
.
getFansId
(),
followRelEntity
.
getIdolId
(),
NotificationTypeEnum
.
FOLLOW
notificationService
.
insert
(
followRelEntity
.
getFansId
(),
followRelEntity
.
getIdolId
(),
NotificationTypeEnum
.
FOLLOW
,
followRelEntity
.
getFansId
(),
""
,
followRelEntity
.
getUpdateTime
());
,
followRelEntity
.
getFansId
(),
""
,
followRelEntity
.
getUpdateTime
());
notificationService
.
putNotifyCacheFollow
(
followRelEntity
.
getIdolId
(),
followRelEntity
.
getFansId
());
notificationService
.
putNotifyCacheFollow
(
followRelEntity
.
getIdolId
(),
followRelEntity
.
getFansId
(),
followRelEntity
.
getUpdateTime
());
}
}
// 转发
// 转发
List
<
ThemeEntity
>
themeEntities
=
themeService
.
queryAllForward
();
List
<
ThemeEntity
>
themeEntities
=
themeService
.
queryAllForward
();
...
@@ -169,7 +169,7 @@ public class NotificationManager {
...
@@ -169,7 +169,7 @@ public class NotificationManager {
NotificationForwardDO
content
=
NotificationForwardDO
.
builder
().
content
(
s
.
length
()
>
500
?
s
.
substring
(
0
,
500
)
:
s
).
topicId
(
themeEntity
.
getTopicId
()).
build
();
NotificationForwardDO
content
=
NotificationForwardDO
.
builder
().
content
(
s
.
length
()
>
500
?
s
.
substring
(
0
,
500
)
:
s
).
topicId
(
themeEntity
.
getTopicId
()).
build
();
notificationService
.
insert
(
themeEntity
.
getAuthorId
(),
former
.
getAuthorId
(),
NotificationTypeEnum
.
FORWARD
notificationService
.
insert
(
themeEntity
.
getAuthorId
(),
former
.
getAuthorId
(),
NotificationTypeEnum
.
FORWARD
,
themeEntity
.
getFormerThemeId
(),
JsonUtil
.
toJson
(
content
),
themeEntity
.
getUpdateTime
());
,
themeEntity
.
getFormerThemeId
(),
JsonUtil
.
toJson
(
content
),
themeEntity
.
getUpdateTime
());
notificationService
.
putNotifyCache
(
former
.
getAuthorId
(),
themeEntity
.
getAuthorId
(),
NotificationTypeEnum
.
FORWARD
);
notificationService
.
putNotifyCache
(
former
.
getAuthorId
(),
themeEntity
.
getAuthorId
(),
NotificationTypeEnum
.
FORWARD
,
themeEntity
.
getUpdateTime
()
);
}
}
// 评论
// 评论
List
<
CommentEntity
>
commentEntities
=
commentService
.
queryAll
();
List
<
CommentEntity
>
commentEntities
=
commentService
.
queryAll
();
...
@@ -181,7 +181,7 @@ public class NotificationManager {
...
@@ -181,7 +181,7 @@ public class NotificationManager {
String
s
=
commentEntity
.
getContent
();
String
s
=
commentEntity
.
getContent
();
notificationService
.
insert
(
commentEntity
.
getAuthorId
(),
themeEntity
.
getAuthorId
(),
NotificationTypeEnum
.
COMMENT
notificationService
.
insert
(
commentEntity
.
getAuthorId
(),
themeEntity
.
getAuthorId
(),
NotificationTypeEnum
.
COMMENT
,
commentEntity
.
getThemeId
(),
s
,
commentEntity
.
getUpdateTime
());
,
commentEntity
.
getThemeId
(),
s
,
commentEntity
.
getUpdateTime
());
notificationService
.
putNotifyCache
(
themeEntity
.
getAuthorId
(),
commentEntity
.
getAuthorId
(),
NotificationTypeEnum
.
COMMENT
);
notificationService
.
putNotifyCache
(
themeEntity
.
getAuthorId
(),
commentEntity
.
getAuthorId
(),
NotificationTypeEnum
.
COMMENT
,
commentEntity
.
getUpdateTime
()
);
}
}
// 点赞
// 点赞
...
@@ -192,7 +192,7 @@ public class NotificationManager {
...
@@ -192,7 +192,7 @@ public class NotificationManager {
continue
;
continue
;
}
}
notificationService
.
insertLike
(
collectionEntity
.
getUserId
(),
themeEntity
.
getAuthorId
(),
collectionEntity
.
getTargetId
(),
collectionEntity
.
getUpdateTime
());
notificationService
.
insertLike
(
collectionEntity
.
getUserId
(),
themeEntity
.
getAuthorId
(),
collectionEntity
.
getTargetId
(),
collectionEntity
.
getUpdateTime
());
notificationService
.
putNotifyCache
(
themeEntity
.
getAuthorId
(),
collectionEntity
.
getUserId
(),
NotificationTypeEnum
.
LIKE
);
notificationService
.
putNotifyCache
(
themeEntity
.
getAuthorId
(),
collectionEntity
.
getUserId
(),
NotificationTypeEnum
.
LIKE
,
collectionEntity
.
getUpdateTime
()
);
}
}
}
}
...
...
community-service/src/main/java/com/tanpu/community/service/NotificationService.java
View file @
b551b892
...
@@ -42,7 +42,7 @@ public class NotificationService {
...
@@ -42,7 +42,7 @@ public class NotificationService {
private
RedisCache
redisCache
;
private
RedisCache
redisCache
;
public
void
insert
(
String
operatorId
,
String
notifierId
,
NotificationTypeEnum
type
,
String
targetId
,
String
content
)
{
public
void
insert
(
String
operatorId
,
String
notifierId
,
NotificationTypeEnum
type
,
String
targetId
,
String
content
)
{
NotificationEntity
entity
=
NotificationEntity
.
builder
().
operatorId
(
operatorId
)
NotificationEntity
entity
=
NotificationEntity
.
builder
().
operatorId
(
operatorId
)
.
notificationId
(
uuidGenHelper
.
getUuidStr
())
.
notificationId
(
uuidGenHelper
.
getUuidStr
())
.
notifiedUserId
(
notifierId
)
.
notifiedUserId
(
notifierId
)
...
@@ -55,7 +55,7 @@ public class NotificationService {
...
@@ -55,7 +55,7 @@ public class NotificationService {
}
}
public
void
insert
(
String
operatorId
,
String
notifierId
,
NotificationTypeEnum
type
,
String
targetId
,
String
content
public
void
insert
(
String
operatorId
,
String
notifierId
,
NotificationTypeEnum
type
,
String
targetId
,
String
content
,
LocalDateTime
createTime
){
,
LocalDateTime
createTime
)
{
NotificationEntity
entity
=
NotificationEntity
.
builder
().
operatorId
(
operatorId
)
NotificationEntity
entity
=
NotificationEntity
.
builder
().
operatorId
(
operatorId
)
.
notificationId
(
uuidGenHelper
.
getUuidStr
())
.
notificationId
(
uuidGenHelper
.
getUuidStr
())
.
notifiedUserId
(
notifierId
)
.
notifiedUserId
(
notifierId
)
...
@@ -70,7 +70,7 @@ public class NotificationService {
...
@@ -70,7 +70,7 @@ public class NotificationService {
}
}
public
void
insertForward
(
String
operatorId
,
String
notifierId
,
String
forwardThemeId
,
String
topicId
,
String
text
,
String
themeId
)
{
public
void
insertForward
(
String
operatorId
,
String
notifierId
,
String
forwardThemeId
,
String
topicId
,
String
text
,
String
themeId
)
{
NotificationForwardDO
forwardDO
=
NotificationForwardDO
.
builder
().
topicId
(
topicId
).
content
(
text
).
themeId
(
themeId
).
build
();
NotificationForwardDO
forwardDO
=
NotificationForwardDO
.
builder
().
topicId
(
topicId
).
content
(
text
).
themeId
(
themeId
).
build
();
NotificationEntity
entity
=
NotificationEntity
.
builder
().
operatorId
(
operatorId
)
NotificationEntity
entity
=
NotificationEntity
.
builder
().
operatorId
(
operatorId
)
.
notificationId
(
uuidGenHelper
.
getUuidStr
())
.
notificationId
(
uuidGenHelper
.
getUuidStr
())
...
@@ -85,18 +85,18 @@ public class NotificationService {
...
@@ -85,18 +85,18 @@ public class NotificationService {
}
}
public
void
insertLike
(
String
operatorId
,
String
notifierId
,
String
targetId
)
{
public
void
insertLike
(
String
operatorId
,
String
notifierId
,
String
targetId
)
{
NotificationEntity
entity
=
notificationMapper
.
selectOne
(
new
LambdaQueryWrapper
<
NotificationEntity
>()
NotificationEntity
entity
=
notificationMapper
.
selectOne
(
new
LambdaQueryWrapper
<
NotificationEntity
>()
.
eq
(
NotificationEntity:
:
getMessageType
,
NotificationTypeEnum
.
LIKE
.
getCode
())
.
eq
(
NotificationEntity:
:
getMessageType
,
NotificationTypeEnum
.
LIKE
.
getCode
())
.
eq
(
NotificationEntity:
:
getTargetId
,
targetId
)
.
eq
(
NotificationEntity:
:
getTargetId
,
targetId
)
.
eq
(
NotificationEntity:
:
getNotifiedUserId
,
notifierId
));
.
eq
(
NotificationEntity:
:
getNotifiedUserId
,
notifierId
));
if
(
entity
!=
null
)
{
if
(
entity
!=
null
)
{
NotificationLikeDO
notificationLikeDO
=
JsonUtil
.
toBean
(
entity
.
getContent
(),
NotificationLikeDO
.
class
);
NotificationLikeDO
notificationLikeDO
=
JsonUtil
.
toBean
(
entity
.
getContent
(),
NotificationLikeDO
.
class
);
notificationLikeDO
.
addItem
(
operatorId
);
notificationLikeDO
.
addItem
(
operatorId
);
entity
.
setContent
(
JsonUtil
.
toJson
(
notificationLikeDO
));
entity
.
setContent
(
JsonUtil
.
toJson
(
notificationLikeDO
));
entity
.
setUpdateTime
(
LocalDateTime
.
now
());
entity
.
setUpdateTime
(
LocalDateTime
.
now
());
notificationMapper
.
updateById
(
entity
);
notificationMapper
.
updateById
(
entity
);
}
else
{
}
else
{
NotificationLikeDO
notificationLikeDO
=
new
NotificationLikeDO
();
NotificationLikeDO
notificationLikeDO
=
new
NotificationLikeDO
();
notificationLikeDO
.
addItem
(
operatorId
);
notificationLikeDO
.
addItem
(
operatorId
);
NotificationEntity
build
=
NotificationEntity
.
builder
().
operatorId
(
operatorId
)
NotificationEntity
build
=
NotificationEntity
.
builder
().
operatorId
(
operatorId
)
...
@@ -113,31 +113,31 @@ public class NotificationService {
...
@@ -113,31 +113,31 @@ public class NotificationService {
}
}
@Transactional
@Transactional
public
void
insert
(
NotificationEntity
entity
){
public
void
insert
(
NotificationEntity
entity
)
{
notificationMapper
.
insert
(
entity
);
notificationMapper
.
insert
(
entity
);
}
}
public
NotificationEntity
queryById
(
String
notificationId
){
public
NotificationEntity
queryById
(
String
notificationId
)
{
return
notificationMapper
.
selectOne
(
new
LambdaQueryWrapper
<
NotificationEntity
>()
return
notificationMapper
.
selectOne
(
new
LambdaQueryWrapper
<
NotificationEntity
>()
.
eq
(
NotificationEntity:
:
getNotificationId
,
notificationId
));
.
eq
(
NotificationEntity:
:
getNotificationId
,
notificationId
));
}
}
public
List
<
NotificationEntity
>
query
(
String
userId
,
Integer
type
,
String
lastId
,
Integer
pageSize
){
public
List
<
NotificationEntity
>
query
(
String
userId
,
Integer
type
,
String
lastId
,
Integer
pageSize
)
{
LambdaQueryWrapper
<
NotificationEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
NotificationEntity
>()
LambdaQueryWrapper
<
NotificationEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
NotificationEntity
>()
.
eq
(
NotificationEntity:
:
getNotifiedUserId
,
userId
)
.
eq
(
NotificationEntity:
:
getNotifiedUserId
,
userId
)
.
orderByDesc
(
NotificationEntity:
:
getUpdateTime
)
.
orderByDesc
(
NotificationEntity:
:
getUpdateTime
)
.
last
(
"limit "
+
pageSize
);
.
last
(
"limit "
+
pageSize
);
if
(
StringUtils
.
isNotBlank
(
lastId
)){
if
(
StringUtils
.
isNotBlank
(
lastId
))
{
NotificationEntity
lastOne
=
notificationMapper
.
selectOne
(
new
LambdaQueryWrapper
<
NotificationEntity
>()
NotificationEntity
lastOne
=
notificationMapper
.
selectOne
(
new
LambdaQueryWrapper
<
NotificationEntity
>()
.
eq
(
NotificationEntity:
:
getNotificationId
,
lastId
));
.
eq
(
NotificationEntity:
:
getNotificationId
,
lastId
));
queryWrapper
.
lt
(
NotificationEntity:
:
getUpdateTime
,
lastOne
.
getCreateTime
());
queryWrapper
.
lt
(
NotificationEntity:
:
getUpdateTime
,
lastOne
.
getCreateTime
());
}
}
if
(!
NotificationTypeEnum
.
ALL
.
getCode
().
equals
(
type
)){
if
(!
NotificationTypeEnum
.
ALL
.
getCode
().
equals
(
type
))
{
queryWrapper
.
eq
(
NotificationEntity:
:
getMessageType
,
type
);
queryWrapper
.
eq
(
NotificationEntity:
:
getMessageType
,
type
);
}
}
return
notificationMapper
.
selectList
(
queryWrapper
);
return
notificationMapper
.
selectList
(
queryWrapper
);
}
}
...
@@ -148,19 +148,19 @@ public class NotificationService {
...
@@ -148,19 +148,19 @@ public class NotificationService {
.
eq
(
NotificationEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()));
.
eq
(
NotificationEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()));
}
}
public
void
insertLike
(
String
operatorId
,
String
notifierId
,
String
targetId
,
LocalDateTime
updateTime
){
public
void
insertLike
(
String
operatorId
,
String
notifierId
,
String
targetId
,
LocalDateTime
updateTime
)
{
NotificationEntity
entity
=
notificationMapper
.
selectOne
(
new
LambdaQueryWrapper
<
NotificationEntity
>()
NotificationEntity
entity
=
notificationMapper
.
selectOne
(
new
LambdaQueryWrapper
<
NotificationEntity
>()
.
eq
(
NotificationEntity:
:
getMessageType
,
NotificationTypeEnum
.
LIKE
.
getCode
())
.
eq
(
NotificationEntity:
:
getMessageType
,
NotificationTypeEnum
.
LIKE
.
getCode
())
.
eq
(
NotificationEntity:
:
getTargetId
,
targetId
)
.
eq
(
NotificationEntity:
:
getTargetId
,
targetId
)
.
eq
(
NotificationEntity:
:
getNotifiedUserId
,
notifierId
));
.
eq
(
NotificationEntity:
:
getNotifiedUserId
,
notifierId
));
if
(
entity
!=
null
)
{
if
(
entity
!=
null
)
{
NotificationLikeDO
notificationLikeDO
=
JsonUtil
.
toBean
(
entity
.
getContent
(),
NotificationLikeDO
.
class
);
NotificationLikeDO
notificationLikeDO
=
JsonUtil
.
toBean
(
entity
.
getContent
(),
NotificationLikeDO
.
class
);
notificationLikeDO
.
addItem
(
operatorId
);
notificationLikeDO
.
addItem
(
operatorId
);
entity
.
setContent
(
JsonUtil
.
toJson
(
notificationLikeDO
));
entity
.
setContent
(
JsonUtil
.
toJson
(
notificationLikeDO
));
entity
.
setUpdateTime
(
updateTime
);
entity
.
setUpdateTime
(
updateTime
);
notificationMapper
.
updateById
(
entity
);
notificationMapper
.
updateById
(
entity
);
}
else
{
}
else
{
NotificationLikeDO
notificationLikeDO
=
new
NotificationLikeDO
();
NotificationLikeDO
notificationLikeDO
=
new
NotificationLikeDO
();
notificationLikeDO
.
addItem
(
operatorId
);
notificationLikeDO
.
addItem
(
operatorId
);
NotificationEntity
build
=
NotificationEntity
.
builder
().
operatorId
(
operatorId
)
NotificationEntity
build
=
NotificationEntity
.
builder
().
operatorId
(
operatorId
)
...
@@ -179,10 +179,10 @@ public class NotificationService {
...
@@ -179,10 +179,10 @@ public class NotificationService {
}
}
// 消息通知队列缓存
// 消息通知队列缓存
public
void
putNotifyCache
(
String
notifyUserId
,
String
operatorId
,
NotificationTypeEnum
type
){
public
void
putNotifyCache
(
String
notifyUserId
,
String
operatorId
,
NotificationTypeEnum
type
)
{
UserInfoResp
userInfo
=
getUserInfo
(
operatorId
);
UserInfoResp
userInfo
=
getUserInfo
(
operatorId
);
redisCache
.
incr
(
RedisKeyConstant
.
MESSAGE_NOTIFY_COUNT
+
notifyUserId
);
redisCache
.
incr
(
RedisKeyConstant
.
MESSAGE_NOTIFY_COUNT
+
notifyUserId
);
redisCache
.
set
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_MSG
+
notifyUserId
,
userInfo
.
getNickName
()
+
type
.
getType
()+
"了你的内容"
,
60
*
60
*
24
*
30
);
redisCache
.
set
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_MSG
+
notifyUserId
,
userInfo
.
getNickName
()
+
type
.
getType
()
+
"了你的内容"
,
60
*
60
*
24
*
30
);
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
);
}
}
...
@@ -203,4 +203,27 @@ public class NotificationService {
...
@@ -203,4 +203,27 @@ public class NotificationService {
return
userInfoNewCommonResp
.
getData
();
return
userInfoNewCommonResp
.
getData
();
}
}
// init用
public
void
putNotifyCache
(
String
notifyUserId
,
String
operatorId
,
NotificationTypeEnum
type
,
LocalDateTime
updateTime
)
{
UserInfoResp
userInfo
=
getUserInfo
(
operatorId
);
redisCache
.
incr
(
RedisKeyConstant
.
MESSAGE_NOTIFY_COUNT
+
notifyUserId
);
String
cacheTime
=
redisCache
.
get
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_TIME
+
notifyUserId
);
if
(
StringUtils
.
isBlank
(
cacheTime
)
||
TimeUtils
.
lessThan
(
cacheTime
,
updateTime
))
{
redisCache
.
set
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_MSG
+
notifyUserId
,
userInfo
.
getNickName
()
+
type
.
getType
()
+
"了你的内容"
,
60
*
60
*
24
*
30
);
redisCache
.
set
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_TIME
+
notifyUserId
,
TimeUtils
.
format
(
LocalDateTime
.
now
()),
60
*
60
*
24
*
30
);
}
}
// init用
public
void
putNotifyCacheFollow
(
String
notifyUserId
,
String
operatorId
,
LocalDateTime
updateTime
)
{
UserInfoResp
userInfo
=
getUserInfo
(
operatorId
);
redisCache
.
incr
(
RedisKeyConstant
.
MESSAGE_NOTIFY_COUNT
+
notifyUserId
);
String
cacheTime
=
redisCache
.
get
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_TIME
+
notifyUserId
);
if
(
StringUtils
.
isBlank
(
cacheTime
)
||
TimeUtils
.
lessThan
(
cacheTime
,
updateTime
))
{
redisCache
.
set
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_MSG
+
notifyUserId
,
userInfo
.
getNickName
()
+
"关注了你"
,
60
*
60
*
24
*
30
);
redisCache
.
set
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_TIME
+
notifyUserId
,
TimeUtils
.
format
(
LocalDateTime
.
now
()),
60
*
60
*
24
*
30
);
}
}
}
}
community-service/src/main/java/com/tanpu/community/service/TopicService.java
View file @
b551b892
package
com
.
tanpu
.
community
.
service
;
package
com
.
tanpu
.
community
.
service
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.tanpu.common.uuid.UuidGenHelper
;
import
com.tanpu.common.uuid.UuidGenHelper
;
import
com.tanpu.community.api.enums.StatusEnum
;
import
com.tanpu.community.api.enums.StatusEnum
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
...
@@ -44,36 +43,6 @@ public class TopicService {
...
@@ -44,36 +43,6 @@ public class TopicService {
public
void
updateTopicToTop
(
String
topicId
)
{
TopicEntity
topicEntity
=
new
TopicEntity
();
topicEntity
.
setIsTop
(
StatusEnum
.
TRUE
.
getCode
());
topicMapper
.
update
(
topicEntity
,
new
LambdaUpdateWrapper
<
TopicEntity
>()
.
eq
(
TopicEntity:
:
getId
,
topicId
));
}
public
void
updateTopicNotTop
(
String
topicId
)
{
TopicEntity
topicEntity
=
new
TopicEntity
();
topicEntity
.
setIsTop
(
StatusEnum
.
FALSE
.
getCode
());
topicMapper
.
update
(
topicEntity
,
new
LambdaUpdateWrapper
<
TopicEntity
>()
.
eq
(
TopicEntity:
:
getId
,
topicId
));
}
public
void
updateTopicToConceal
(
String
topicId
)
{
TopicEntity
topicEntity
=
new
TopicEntity
();
topicEntity
.
setIsConceal
(
StatusEnum
.
TRUE
.
getCode
());
topicMapper
.
update
(
topicEntity
,
new
LambdaUpdateWrapper
<
TopicEntity
>()
.
eq
(
TopicEntity:
:
getId
,
topicId
));
}
public
void
updateTopicNotConceal
(
String
topicId
)
{
TopicEntity
topicEntity
=
new
TopicEntity
();
topicEntity
.
setIsConceal
(
StatusEnum
.
FALSE
.
getCode
());
topicMapper
.
update
(
topicEntity
,
new
LambdaUpdateWrapper
<
TopicEntity
>()
.
eq
(
TopicEntity:
:
getId
,
topicId
));
}
public
TopicEntity
queryById
(
String
topicId
)
{
public
TopicEntity
queryById
(
String
topicId
)
{
return
topicMapper
.
selectOne
(
new
LambdaQueryWrapper
<
TopicEntity
>()
return
topicMapper
.
selectOne
(
new
LambdaQueryWrapper
<
TopicEntity
>()
.
eq
(
TopicEntity:
:
getTopicId
,
topicId
)
.
eq
(
TopicEntity:
:
getTopicId
,
topicId
)
...
@@ -95,7 +64,4 @@ public class TopicService {
...
@@ -95,7 +64,4 @@ public class TopicService {
return
topicMapper
.
selectList
(
new
LambdaQueryWrapper
<
TopicEntity
>().
in
(
TopicEntity:
:
getTopicId
,
topicIds
));
return
topicMapper
.
selectList
(
new
LambdaQueryWrapper
<
TopicEntity
>().
in
(
TopicEntity:
:
getTopicId
,
topicIds
));
}
}
public
TopicEntity
queryByTitile
(
String
topicTitle
)
{
return
topicMapper
.
selectOne
(
new
LambdaQueryWrapper
<
TopicEntity
>().
eq
(
TopicEntity:
:
getTopicTitle
,
topicTitle
));
}
}
}
community-service/src/main/java/com/tanpu/community/util/TimeUtils.java
View file @
b551b892
...
@@ -42,6 +42,11 @@ public class TimeUtils {
...
@@ -42,6 +42,11 @@ public class TimeUtils {
return
start
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm"
));
return
start
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm"
));
}
}
public
static
LocalDateTime
reFormat
(
String
time
)
{
return
LocalDateTime
.
parse
(
time
,
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm"
));
}
//计算迄今分钟
//计算迄今分钟
public
static
long
calMinuteTillNow
(
LocalDateTime
start
)
{
public
static
long
calMinuteTillNow
(
LocalDateTime
start
)
{
if
(
start
==
null
){
if
(
start
==
null
){
...
@@ -93,4 +98,8 @@ public class TimeUtils {
...
@@ -93,4 +98,8 @@ public class TimeUtils {
System
.
out
.
println
(
calUpToNowTime
(
LocalDateTime
.
now
().
minusSeconds
(
12
)));
System
.
out
.
println
(
calUpToNowTime
(
LocalDateTime
.
now
().
minusSeconds
(
12
)));
}
}
public
static
boolean
lessThan
(
String
cacheTime
,
LocalDateTime
updateTime
)
{
if
(
calMillisTillNow
(
reFormat
(
cacheTime
))<
calMillisTillNow
(
updateTime
))
return
true
;
return
false
;
}
}
}
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