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
0c953467
Commit
0c953467
authored
Aug 27, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步评论转发,评论点赞消息通知
parent
d1d79e13
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
124 additions
and
31 deletions
+124
-31
CreateCommentReq.java
...npu/community/api/beans/req/comment/CreateCommentReq.java
+3
-0
ForwardThemeReq.java
.../tanpu/community/api/beans/req/theme/ForwardThemeReq.java
+5
-2
ThemeContentReq.java
.../tanpu/community/api/beans/req/theme/ThemeContentReq.java
+6
-0
BizConstant.java
...n/java/com/tanpu/community/api/constants/BizConstant.java
+16
-0
NotificationTypeEnum.java
...a/com/tanpu/community/api/enums/NotificationTypeEnum.java
+1
-0
CommentManager.java
...main/java/com/tanpu/community/manager/CommentManager.java
+13
-5
HomePageManager.java
...ain/java/com/tanpu/community/manager/HomePageManager.java
+1
-1
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+12
-8
CollectionService.java
...n/java/com/tanpu/community/service/CollectionService.java
+23
-3
CommentService.java
...main/java/com/tanpu/community/service/CommentService.java
+16
-1
NotificationService.java
...java/com/tanpu/community/service/NotificationService.java
+8
-11
ThemeService.java
...c/main/java/com/tanpu/community/service/ThemeService.java
+20
-0
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/req/comment/CreateCommentReq.java
View file @
0c953467
...
@@ -24,4 +24,7 @@ public class CreateCommentReq {
...
@@ -24,4 +24,7 @@ public class CreateCommentReq {
@ApiModelProperty
(
value
=
"评论内容"
)
@ApiModelProperty
(
value
=
"评论内容"
)
private
String
comment
;
private
String
comment
;
@ApiModelProperty
(
value
=
"同步转发,1 同步 ,0 不同步(默认)"
)
private
int
syncForward
=
0
;
}
}
community-api/src/main/java/com/tanpu/community/api/beans/req/theme/ForwardThemeReq.java
View file @
0c953467
...
@@ -21,8 +21,11 @@ public class ForwardThemeReq {
...
@@ -21,8 +21,11 @@ public class ForwardThemeReq {
private
List
<
ThemeContentReq
>
content
;
private
List
<
ThemeContentReq
>
content
;
@ApiModelProperty
(
value
=
"话题Id"
)
@ApiModelProperty
(
value
=
"话题Id"
)
private
String
topicId
=
""
;
private
String
topicId
=
""
;
@ApiModelProperty
(
value
=
"修改,则传入正在编辑的ThemeId"
)
@ApiModelProperty
(
value
=
"修改,则传入正在编辑的ThemeId"
)
private
String
editThemeId
=
""
;
private
String
editThemeId
=
""
;
@ApiModelProperty
(
value
=
"同步评论,1 同步 ,0 不同步(默认)"
)
private
int
syncComment
=
0
;
}
}
community-api/src/main/java/com/tanpu/community/api/beans/req/theme/ThemeContentReq.java
View file @
0c953467
...
@@ -3,12 +3,18 @@ package com.tanpu.community.api.beans.req.theme;
...
@@ -3,12 +3,18 @@ package com.tanpu.community.api.beans.req.theme;
import
com.tanpu.community.api.beans.vo.ImagesDTO
;
import
com.tanpu.community.api.beans.vo.ImagesDTO
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.List
;
import
java.util.List
;
@Data
@Data
@ApiModel
(
value
=
"主题内容"
)
@ApiModel
(
value
=
"主题内容"
)
@Builder
@AllArgsConstructor
@NoArgsConstructor
public
class
ThemeContentReq
{
public
class
ThemeContentReq
{
@ApiModelProperty
(
value
=
"RelTypeEnum类型,108:文本,88:产品 3:直播 6:短视频 303:新版课程-视频,304: 新版课程-音频,109:单图(长文) 110:多图(讨论))"
)
@ApiModelProperty
(
value
=
"RelTypeEnum类型,108:文本,88:产品 3:直播 6:短视频 303:新版课程-视频,304: 新版课程-音频,109:单图(长文) 110:多图(讨论))"
)
...
...
community-api/src/main/java/com/tanpu/community/api/constants/BizConstant.java
0 → 100644
View file @
0c953467
package
com
.
tanpu
.
community
.
api
.
constants
;
public
class
BizConstant
{
public
static
class
SyncCommentType
{
public
static
final
int
SYNC_COMMENT
=
1
;
public
static
final
int
NOT_SYNC_COMMENT
=
0
;
}
public
static
class
SyncForwardType
{
public
static
final
int
SYNC_FORWARD
=
1
;
public
static
final
int
NOT_SYNC_FORWARD
=
0
;
}
}
community-api/src/main/java/com/tanpu/community/api/enums/NotificationTypeEnum.java
View file @
0c953467
...
@@ -12,6 +12,7 @@ public enum NotificationTypeEnum {
...
@@ -12,6 +12,7 @@ public enum NotificationTypeEnum {
LIKE
(
2
,
"点赞"
),
LIKE
(
2
,
"点赞"
),
COMMENT
(
3
,
"评论"
),
COMMENT
(
3
,
"评论"
),
FOLLOW
(
4
,
"关注"
),
FOLLOW
(
4
,
"关注"
),
COMMENT_LIKE
(
5
,
"点赞评论"
),
ALL
(
0
,
"全部"
);
ALL
(
0
,
"全部"
);
private
Integer
code
;
private
Integer
code
;
...
...
community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
View file @
0c953467
...
@@ -10,6 +10,7 @@ import com.tanpu.community.api.beans.req.comment.CreateCommentReq;
...
@@ -10,6 +10,7 @@ import com.tanpu.community.api.beans.req.comment.CreateCommentReq;
import
com.tanpu.community.api.beans.req.comment.LikeCommentReq
;
import
com.tanpu.community.api.beans.req.comment.LikeCommentReq
;
import
com.tanpu.community.api.beans.req.comment.ReportCommentReq
;
import
com.tanpu.community.api.beans.req.comment.ReportCommentReq
;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp
;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp
;
import
com.tanpu.community.api.constants.BizConstant
;
import
com.tanpu.community.api.enums.NotificationTypeEnum
;
import
com.tanpu.community.api.enums.NotificationTypeEnum
;
import
com.tanpu.community.api.enums.OperationTypeEnum
;
import
com.tanpu.community.api.enums.OperationTypeEnum
;
import
com.tanpu.community.cache.RedisCache
;
import
com.tanpu.community.cache.RedisCache
;
...
@@ -28,7 +29,6 @@ import org.springframework.stereotype.Service;
...
@@ -28,7 +29,6 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.Comparator
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -71,7 +71,6 @@ public class CommentManager {
...
@@ -71,7 +71,6 @@ public class CommentManager {
throw
new
IllegalArgumentException
(
"评论内容不能超过500字"
);
throw
new
IllegalArgumentException
(
"评论内容不能超过500字"
);
}
}
LocalDateTime
now
=
LocalDateTime
.
now
();
CommentEntity
commentEntity
=
CommentEntity
.
builder
()
CommentEntity
commentEntity
=
CommentEntity
.
builder
()
.
themeId
(
req
.
getThemeId
())
.
themeId
(
req
.
getThemeId
())
.
parentId
(
req
.
getParentId
())
.
parentId
(
req
.
getParentId
())
...
@@ -79,18 +78,27 @@ public class CommentManager {
...
@@ -79,18 +78,27 @@ public class CommentManager {
.
authorId
(
userId
)
.
authorId
(
userId
)
.
content
(
req
.
getComment
())
.
content
(
req
.
getComment
())
.
commentType
(
CommentTypeEnum
.
THEME
.
getCode
())
.
commentType
(
CommentTypeEnum
.
THEME
.
getCode
())
.
createTime
(
now
)
.
updateTime
(
now
)
.
build
();
.
build
();
commentService
.
insertComment
(
commentEntity
);
commentService
.
insertComment
(
commentEntity
);
CommentQo
commentQo
=
ConvertUtil
.
commentEntity2Qo
(
commentEntity
);
CommentQo
commentQo
=
ConvertUtil
.
commentEntity2Qo
(
commentEntity
);
buildUserInfo
(
commentQo
);
buildUserInfo
(
commentQo
);
// 消息通知
// 消息通知
ThemeEntity
themeEntity
=
themeService
.
queryByThemeId
(
req
.
getThemeId
());
ThemeEntity
themeEntity
=
themeService
.
queryByThemeId
(
req
.
getThemeId
());
notificationService
.
insert
(
userId
,
themeEntity
.
getAuthorId
(),
NotificationTypeEnum
.
COMMENT
,
commentEntity
.
getCommentId
(),
req
.
getComment
());
notificationService
.
insert
(
userId
,
themeEntity
.
getAuthorId
(),
NotificationTypeEnum
.
COMMENT
,
commentEntity
.
getCommentId
(),
req
.
getComment
());
notificationService
.
putNotifyCache
(
themeEntity
.
getAuthorId
(),
userId
,
NotificationTypeEnum
.
COMMENT
);
notificationService
.
putNotifyCache
(
themeEntity
.
getAuthorId
(),
userId
,
NotificationTypeEnum
.
COMMENT
);
// 评论同步转发并消息通知
if
(
req
.
getSyncForward
()
==
BizConstant
.
SyncForwardType
.
SYNC_FORWARD
)
{
String
themeId
=
themeService
.
commentSyncForward
(
req
,
userId
);
// 消息通知
ThemeEntity
formerTheme
=
themeService
.
queryByThemeId
(
req
.
getThemeId
());
notificationService
.
insertForward
(
userId
,
formerTheme
.
getAuthorId
(),
formerTheme
.
getThemeId
(),
""
,
req
.
getComment
(),
themeEntity
.
getThemeId
());
notificationService
.
putNotifyCache
(
formerTheme
.
getAuthorId
(),
userId
,
NotificationTypeEnum
.
FORWARD
);
}
return
commentQo
;
return
commentQo
;
}
}
...
...
community-service/src/main/java/com/tanpu/community/manager/HomePageManager.java
View file @
0c953467
...
@@ -247,7 +247,7 @@ public class HomePageManager {
...
@@ -247,7 +247,7 @@ public class HomePageManager {
// 第一次关注才有消息通知
// 第一次关注才有消息通知
if
(
followRelService
.
addFollowRel
(
req
.
getFollowUserId
(),
followerId
))
{
if
(
followRelService
.
addFollowRel
(
req
.
getFollowUserId
(),
followerId
))
{
notificationService
.
insert
(
followerId
,
req
.
getFollowUserId
(),
NotificationTypeEnum
.
FOLLOW
,
req
.
getFollowUserId
(),
null
);
notificationService
.
insert
(
followerId
,
req
.
getFollowUserId
(),
NotificationTypeEnum
.
FOLLOW
,
req
.
getFollowUserId
(),
null
);
notificationService
.
putNotifyCache
Follow
(
req
.
getFollowUserId
(),
followerId
);
notificationService
.
putNotifyCache
(
req
.
getFollowUserId
(),
followerId
,
NotificationTypeEnum
.
FOLLOW
);
}
}
}
else
if
(
OperationTypeEnum
.
CANCEL
.
getCode
().
equals
(
req
.
getType
()))
{
}
else
if
(
OperationTypeEnum
.
CANCEL
.
getCode
().
equals
(
req
.
getType
()))
{
followRelService
.
deleteFollowRel
(
req
.
getFollowUserId
(),
followerId
);
followRelService
.
deleteFollowRel
(
req
.
getFollowUserId
(),
followerId
);
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
0c953467
...
@@ -32,6 +32,7 @@ import com.tanpu.community.api.beans.vo.ImagesDTO;
...
@@ -32,6 +32,7 @@ import com.tanpu.community.api.beans.vo.ImagesDTO;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp
;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp
;
import
com.tanpu.community.api.beans.vo.feign.newsfeed.NewsFeedResReq
;
import
com.tanpu.community.api.beans.vo.feign.newsfeed.NewsFeedResReq
;
import
com.tanpu.community.api.beans.vo.feign.newsfeed.NewsFeedSave4NewCommReq
;
import
com.tanpu.community.api.beans.vo.feign.newsfeed.NewsFeedSave4NewCommReq
;
import
com.tanpu.community.api.constants.BizConstant
;
import
com.tanpu.community.api.enums.BlockTypeEnum
;
import
com.tanpu.community.api.enums.BlockTypeEnum
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.NotificationTypeEnum
;
import
com.tanpu.community.api.enums.NotificationTypeEnum
;
...
@@ -205,11 +206,6 @@ public class ThemeManager {
...
@@ -205,11 +206,6 @@ public class ThemeManager {
// 校验参数
// 校验参数
checkAttachment
(
req
.
getContent
());
checkAttachment
(
req
.
getContent
());
// 转播权限校验
// if (1 == req.getSyncToNewComm()) {
// liveRelayCheck(userId, req.getContent());
// }
// 保存主题表
// 保存主题表
ThemeEntity
themeEntity
=
new
ThemeEntity
();
ThemeEntity
themeEntity
=
new
ThemeEntity
();
...
@@ -414,8 +410,8 @@ public class ThemeManager {
...
@@ -414,8 +410,8 @@ public class ThemeManager {
themeService
.
insertTheme
(
themeEntity
);
themeService
.
insertTheme
(
themeEntity
);
// 消息通知
// 消息通知
ThemeEntity
formerTheme
=
themeService
.
queryByThemeId
(
req
.
getFormerThemeId
());
ThemeEntity
formerTheme
=
themeService
.
queryByThemeId
(
req
.
getFormerThemeId
());
notificationService
.
insertForward
(
userId
,
formerTheme
.
getAuthorId
(),
formerTheme
.
getThemeId
(),
req
.
getTopicId
(),
req
.
getContent
().
get
(
0
).
getValue
(),
themeEntity
.
getThemeId
());
notificationService
.
insertForward
(
userId
,
formerTheme
.
getAuthorId
(),
formerTheme
.
getThemeId
(),
req
.
getTopicId
(),
req
.
getContent
().
get
(
0
).
getValue
(),
themeEntity
.
getThemeId
());
notificationService
.
putNotifyCache
(
formerTheme
.
getAuthorId
(),
userId
,
NotificationTypeEnum
.
FORWARD
);
notificationService
.
putNotifyCache
(
formerTheme
.
getAuthorId
(),
userId
,
NotificationTypeEnum
.
FORWARD
);
}
else
{
}
else
{
// 修改
// 修改
...
@@ -423,6 +419,14 @@ public class ThemeManager {
...
@@ -423,6 +419,14 @@ public class ThemeManager {
themeEntity
.
setThemeId
(
req
.
getEditThemeId
());
themeEntity
.
setThemeId
(
req
.
getEditThemeId
());
this
.
evictThemeCache
(
req
.
getEditThemeId
());
this
.
evictThemeCache
(
req
.
getEditThemeId
());
}
}
// 转发同步评论并消息通知
if
(
req
.
getSyncComment
()
==
BizConstant
.
SyncCommentType
.
SYNC_COMMENT
)
{
String
commentId
=
commentService
.
forwardSyncComment
(
req
,
userId
);
ThemeEntity
formerTheme
=
themeService
.
queryByThemeId
(
req
.
getFormerThemeId
());
notificationService
.
insert
(
userId
,
formerTheme
.
getAuthorId
(),
NotificationTypeEnum
.
COMMENT
,
commentId
,
req
.
getContent
().
get
(
0
).
getValue
());
notificationService
.
putNotifyCache
(
formerTheme
.
getAuthorId
(),
userId
,
NotificationTypeEnum
.
COMMENT
);
}
try
{
try
{
esService
.
insertOrUpdateTheme
(
ConvertUtil
.
convert
(
themeEntity
));
esService
.
insertOrUpdateTheme
(
ConvertUtil
.
convert
(
themeEntity
));
...
@@ -671,7 +675,7 @@ public class ThemeManager {
...
@@ -671,7 +675,7 @@ public class ThemeManager {
ThemeEntity
themeEntity
=
themeService
.
queryByThemeId
(
req
.
getThemeId
());
ThemeEntity
themeEntity
=
themeService
.
queryByThemeId
(
req
.
getThemeId
());
// 消息通知
// 消息通知
notificationService
.
insertLike
(
userId
,
themeEntity
.
getAuthorId
(),
req
.
getThemeId
());
notificationService
.
insertLike
(
userId
,
themeEntity
.
getAuthorId
(),
req
.
getThemeId
());
notificationService
.
putNotifyCache
(
themeEntity
.
getAuthorId
(),
userId
,
NotificationTypeEnum
.
LIKE
);
notificationService
.
putNotifyCache
(
themeEntity
.
getAuthorId
(),
userId
,
NotificationTypeEnum
.
LIKE
);
}
}
}
else
if
(
OperationTypeEnum
.
CANCEL
.
getCode
().
equals
(
req
.
getType
()))
{
}
else
if
(
OperationTypeEnum
.
CANCEL
.
getCode
().
equals
(
req
.
getType
()))
{
...
...
community-service/src/main/java/com/tanpu/community/service/CollectionService.java
View file @
0c953467
...
@@ -3,11 +3,15 @@ package com.tanpu.community.service;
...
@@ -3,11 +3,15 @@ package com.tanpu.community.service;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.tanpu.biz.common.enums.community.CollectionTypeEnum
;
import
com.tanpu.biz.common.enums.community.CollectionTypeEnum
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
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.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.entity.community.TimesCountEntity
;
import
com.tanpu.community.dao.mapper.community.CollectionMapper
;
import
com.tanpu.community.dao.mapper.community.CollectionMapper
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -26,15 +30,24 @@ public class CollectionService {
...
@@ -26,15 +30,24 @@ public class CollectionService {
@Resource
@Resource
private
CollectionMapper
collectionMapper
;
private
CollectionMapper
collectionMapper
;
@Autowired
private
NotificationService
notificationService
;
@Autowired
private
ThemeService
themeService
;
@Autowired
private
CommentService
commentService
;
// 若不存在则新增,若存在则修改deleteTag
// 若不存在则新增,若存在则修改deleteTag
@Transactional
@Transactional
public
boolean
saveOrUpdate
(
String
t
heme
Id
,
String
userId
,
CollectionTypeEnum
type
)
{
public
boolean
saveOrUpdate
(
String
t
arget
Id
,
String
userId
,
CollectionTypeEnum
type
)
{
// 判断记录是否存在,无论是否删除
// 判断记录是否存在,无论是否删除
LambdaQueryWrapper
<
CollectionEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
CollectionEntity
>()
LambdaQueryWrapper
<
CollectionEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
CollectionEntity
>()
.
eq
(
CollectionEntity:
:
getCollectionType
,
type
.
getCode
())
.
eq
(
CollectionEntity:
:
getCollectionType
,
type
.
getCode
())
.
eq
(
CollectionEntity:
:
getUserId
,
userId
)
.
eq
(
CollectionEntity:
:
getUserId
,
userId
)
.
eq
(
CollectionEntity:
:
getTargetId
,
t
heme
Id
);
.
eq
(
CollectionEntity:
:
getTargetId
,
t
arget
Id
);
CollectionEntity
queryCollection
=
collectionMapper
.
selectOne
(
queryWrapper
);
CollectionEntity
queryCollection
=
collectionMapper
.
selectOne
(
queryWrapper
);
if
(
queryCollection
!=
null
)
{
if
(
queryCollection
!=
null
)
{
queryCollection
.
setDeleteTag
(
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
queryCollection
.
setDeleteTag
(
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
...
@@ -45,11 +58,18 @@ public class CollectionService {
...
@@ -45,11 +58,18 @@ public class CollectionService {
CollectionEntity
entity
=
CollectionEntity
.
builder
()
CollectionEntity
entity
=
CollectionEntity
.
builder
()
.
collectionType
(
type
.
getCode
())
.
collectionType
(
type
.
getCode
())
.
userId
(
userId
)
.
userId
(
userId
)
.
targetId
(
t
heme
Id
)
.
targetId
(
t
arget
Id
)
.
collectionTime
(
LocalDateTime
.
now
())
.
collectionTime
(
LocalDateTime
.
now
())
.
build
();
.
build
();
collectionMapper
.
insert
(
entity
);
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
;
return
true
;
}
}
}
}
...
...
community-service/src/main/java/com/tanpu/community/service/CommentService.java
View file @
0c953467
...
@@ -6,6 +6,7 @@ import com.tanpu.biz.common.enums.community.CommentTypeEnum;
...
@@ -6,6 +6,7 @@ import com.tanpu.biz.common.enums.community.CommentTypeEnum;
import
com.tanpu.biz.common.enums.community.ReportStatusEnum
;
import
com.tanpu.biz.common.enums.community.ReportStatusEnum
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.common.uuid.UuidGenHelper
;
import
com.tanpu.common.uuid.UuidGenHelper
;
import
com.tanpu.community.api.beans.req.theme.ForwardThemeReq
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.cache.RedisCache
;
import
com.tanpu.community.cache.RedisCache
;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
...
@@ -44,7 +45,6 @@ public class CommentService {
...
@@ -44,7 +45,6 @@ public class CommentService {
//失效缓存
//失效缓存
evictThemeCache
(
commentEntity
.
getThemeId
());
evictThemeCache
(
commentEntity
.
getThemeId
());
}
}
...
@@ -163,4 +163,19 @@ public class CommentService {
...
@@ -163,4 +163,19 @@ public class CommentService {
public
CommentEntity
queryByCommentId
(
String
commentId
)
{
public
CommentEntity
queryByCommentId
(
String
commentId
)
{
return
commentMapper
.
selectOne
(
new
LambdaQueryWrapper
<
CommentEntity
>().
eq
(
CommentEntity:
:
getCommentId
,
commentId
));
return
commentMapper
.
selectOne
(
new
LambdaQueryWrapper
<
CommentEntity
>().
eq
(
CommentEntity:
:
getCommentId
,
commentId
));
}
}
public
String
forwardSyncComment
(
ForwardThemeReq
req
,
String
userId
)
{
CommentEntity
commentEntity
=
CommentEntity
.
builder
()
.
themeId
(
req
.
getFormerThemeId
())
.
authorId
(
userId
)
.
content
(
req
.
getContent
().
get
(
0
).
getValue
())
.
commentType
(
CommentTypeEnum
.
THEME
.
getCode
())
.
build
();
this
.
insertComment
(
commentEntity
);
return
commentEntity
.
getCommentId
();
}
}
}
community-service/src/main/java/com/tanpu/community/service/NotificationService.java
View file @
0c953467
...
@@ -182,17 +182,14 @@ public class NotificationService {
...
@@ -182,17 +182,14 @@ 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_TIME
+
notifyUserId
,
TimeUtils
.
format
(
LocalDateTime
.
now
()),
60
*
60
*
24
*
30
);
}
// 消息通知队列缓存
public
void
putNotifyCacheFollow
(
String
notifyUserId
,
String
operatorId
)
{
UserInfoResp
userInfo
=
getUserInfo
(
operatorId
);
redisCache
.
incr
(
RedisKeyConstant
.
MESSAGE_NOTIFY_COUNT
+
notifyUserId
);
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
);
redisCache
.
set
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_TIME
+
notifyUserId
,
TimeUtils
.
format
(
LocalDateTime
.
now
()),
60
*
60
*
24
*
30
);
if
(
NotificationTypeEnum
.
COMMENT_LIKE
.
equals
(
type
))
{
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
{
redisCache
.
set
(
RedisKeyConstant
.
MESSAGE_NOTIFY_LAST_MSG
+
notifyUserId
,
userInfo
.
getNickName
()
+
type
.
getType
()
+
"了你的内容"
,
60
*
60
*
24
*
30
);
}
}
}
...
@@ -231,7 +228,7 @@ public class NotificationService {
...
@@ -231,7 +228,7 @@ public class NotificationService {
// 处理更新数量
// 处理更新数量
String
lastTime
=
redisCache
.
get
(
RedisKeyConstant
.
MESSAGE_NOTIFY_QUERY_TIME
+
notifyUserId
);
String
lastTime
=
redisCache
.
get
(
RedisKeyConstant
.
MESSAGE_NOTIFY_QUERY_TIME
+
notifyUserId
);
LocalDateTime
lastQueryTime
=
StringUtils
.
isNotBlank
(
lastTime
)?
JsonUtil
.
toBean
(
lastTime
,
LocalDateTime
.
class
):
LocalDateTime
.
now
();
LocalDateTime
lastQueryTime
=
StringUtils
.
isNotBlank
(
lastTime
)
?
JsonUtil
.
toBean
(
lastTime
,
LocalDateTime
.
class
)
:
LocalDateTime
.
now
();
// 如果删除的评论时时间在红点提示时间内,则缓存数-1
// 如果删除的评论时时间在红点提示时间内,则缓存数-1
if
(
StringUtils
.
isBlank
(
lastTime
)
||
TimeUtils
.
lessThan
(
lastQueryTime
,
commentTime
))
{
if
(
StringUtils
.
isBlank
(
lastTime
)
||
TimeUtils
.
lessThan
(
lastQueryTime
,
commentTime
))
{
redisCache
.
decr
(
RedisKeyConstant
.
MESSAGE_NOTIFY_COUNT
+
notifyUserId
);
redisCache
.
decr
(
RedisKeyConstant
.
MESSAGE_NOTIFY_COUNT
+
notifyUserId
);
...
...
community-service/src/main/java/com/tanpu/community/service/ThemeService.java
View file @
0c953467
...
@@ -2,10 +2,14 @@ package com.tanpu.community.service;
...
@@ -2,10 +2,14 @@ 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.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.tanpu.biz.common.enums.RelTypeEnum
;
import
com.tanpu.biz.common.enums.community.ReportStatusEnum
;
import
com.tanpu.biz.common.enums.community.ReportStatusEnum
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.common.redis.RedisHelper
;
import
com.tanpu.common.redis.RedisHelper
;
import
com.tanpu.common.util.JsonUtil
;
import
com.tanpu.common.uuid.UuidGenHelper
;
import
com.tanpu.common.uuid.UuidGenHelper
;
import
com.tanpu.community.api.beans.req.comment.CreateCommentReq
;
import
com.tanpu.community.api.beans.req.theme.ThemeContentReq
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.ThemeTypeEnum
;
import
com.tanpu.community.api.enums.ThemeTypeEnum
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
...
@@ -19,6 +23,7 @@ import org.springframework.stereotype.Service;
...
@@ -19,6 +23,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.HashSet
;
...
@@ -275,4 +280,19 @@ public class ThemeService {
...
@@ -275,4 +280,19 @@ public class ThemeService {
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
orderByAsc
(
ThemeEntity:
:
getCreateTime
));
.
orderByAsc
(
ThemeEntity:
:
getCreateTime
));
}
}
public
String
commentSyncForward
(
CreateCommentReq
req
,
String
userId
)
{
// 评论构造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
();
ThemeEntity
themeEntity
=
ThemeEntity
.
builder
()
.
content
(
JsonUtil
.
toJson
(
themeContentReqs
))
.
topicId
(
""
)
.
formerThemeId
(
req
.
getThemeId
())
.
authorId
(
userId
)
.
themeType
(
ThemeTypeEnum
.
FORWARD
.
getCode
())
.
build
();
this
.
insertTheme
(
themeEntity
);
return
themeEntity
.
getThemeId
();
}
}
}
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