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
c9b7209f
Commit
c9b7209f
authored
Feb 25, 2022
by
刘基明
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v2.3.1' into 'dev'
递归删除评论的回复 See merge request
!87
parents
bb51b554
647df1e7
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
20 deletions
+35
-20
ThemeMapper.java
...com/tanpu/community/dao/mapper/community/ThemeMapper.java
+1
-0
CommentManager.java
...main/java/com/tanpu/community/manager/CommentManager.java
+13
-6
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+3
-2
CommentService.java
...main/java/com/tanpu/community/service/CommentService.java
+2
-1
ThemeService.java
...c/main/java/com/tanpu/community/service/ThemeService.java
+1
-1
ThemeEntityMapper.xml
...src/main/resources/mapper/community/ThemeEntityMapper.xml
+15
-10
No files found.
community-service/src/main/java/com/tanpu/community/dao/mapper/community/ThemeMapper.java
View file @
c9b7209f
...
@@ -43,4 +43,5 @@ public interface ThemeMapper extends BaseMapper<ThemeEntity> {
...
@@ -43,4 +43,5 @@ public interface ThemeMapper extends BaseMapper<ThemeEntity> {
@Param
(
"pageStart"
)
Integer
pageStart
,
@Param
(
"pageSize"
)
Integer
pageSize
);
@Param
(
"pageStart"
)
Integer
pageStart
,
@Param
(
"pageSize"
)
Integer
pageSize
);
}
}
community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
View file @
c9b7209f
...
@@ -104,10 +104,10 @@ public class CommentManager {
...
@@ -104,10 +104,10 @@ public class CommentManager {
// 一级回复通知发帖人,二级回复通知一级评论人
// 一级回复通知发帖人,二级回复通知一级评论人
if
(
StringUtils
.
isNotBlank
(
req
.
getReplyUserId
())){
if
(
StringUtils
.
isNotBlank
(
req
.
getReplyUserId
()))
{
notificationService
.
insert
(
userId
,
req
.
getReplyUserId
(),
NotificationTypeEnum
.
COMMENT_REPLY
,
commentEntity
.
getCommentId
(),
req
.
getComment
());
notificationService
.
insert
(
userId
,
req
.
getReplyUserId
(),
NotificationTypeEnum
.
COMMENT_REPLY
,
commentEntity
.
getCommentId
(),
req
.
getComment
());
notificationService
.
putNotifyCache
(
req
.
getReplyUserId
(),
userId
,
NotificationTypeEnum
.
COMMENT_REPLY
);
notificationService
.
putNotifyCache
(
req
.
getReplyUserId
(),
userId
,
NotificationTypeEnum
.
COMMENT_REPLY
);
}
else
{
}
else
{
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
);
...
@@ -233,10 +233,17 @@ public class CommentManager {
...
@@ -233,10 +233,17 @@ public class CommentManager {
if
(
StringUtils
.
isBlank
(
commentId
))
{
if
(
StringUtils
.
isBlank
(
commentId
))
{
throw
new
BizException
(
"commentId不能为空"
);
throw
new
BizException
(
"commentId不能为空"
);
}
}
commentService
.
delete
(
commentId
,
userId
);
// 循环删除二级评论的一级评论
CommentEntity
commentEntity
=
commentService
.
queryByIdIncludeDelete
(
commentId
);
while
(
StringUtils
.
isNotBlank
(
commentId
))
{
// 逻辑删除comment
CommentEntity
commentEntity
=
commentService
.
delete
(
commentId
,
userId
);
// 删除站内信
ThemeEntity
themeEntity
=
themeService
.
queryByThemeId
(
commentEntity
.
getThemeId
());
ThemeEntity
themeEntity
=
themeService
.
queryByThemeId
(
commentEntity
.
getThemeId
());
notificationService
.
deleteCommentNotify
(
themeEntity
.
getAuthorId
(),
userId
,
commentId
,
commentEntity
.
getCreateTime
());
notificationService
.
deleteCommentNotify
(
themeEntity
.
getAuthorId
(),
userId
,
commentId
,
commentEntity
.
getCreateTime
());
// 递归
commentId
=
commentEntity
.
getReplyId
();
userId
=
commentEntity
.
getReplyUserId
();
}
}
}
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
c9b7209f
...
@@ -510,14 +510,15 @@ public class ThemeManager {
...
@@ -510,14 +510,15 @@ public class ThemeManager {
}
else
if
(
ThemeListTypeEnum
.
FOLLOW
.
getCode
().
equals
(
req
.
getType
()))
{
}
else
if
(
ThemeListTypeEnum
.
FOLLOW
.
getCode
().
equals
(
req
.
getType
()))
{
if
(
StringUtils
.
isEmpty
(
req
.
getUserId
()
))
{
if
(
StringUtils
.
isEmpty
(
userId
))
{
// 未登录情况下返回空数组
// 未登录情况下返回空数组
themes
=
Lists
.
newArrayListWithCapacity
(
0
);
themes
=
Lists
.
newArrayListWithCapacity
(
0
);
}
else
{
}
else
{
// 根据关注列表查询,按时间倒序
// 根据关注列表查询,按时间倒序
List
<
String
>
fansList
=
followRelService
.
queryIdolsByFansId
(
req
.
getUserId
());
List
<
String
>
fansList
=
followRelService
.
queryIdolsByFansId
(
req
.
getUserId
());
fansList
.
add
(
userId
);
// 保证fansList不为空
// 权限控制,筛选出当前用户
有权限
的话题
// 权限控制,筛选出当前用户
关注
的话题
Set
<
String
>
userPermitTopics
=
topicService
.
getUserPermitTopics
(
userId
);
Set
<
String
>
userPermitTopics
=
topicService
.
getUserPermitTopics
(
userId
);
// 查库
// 查库
...
...
community-service/src/main/java/com/tanpu/community/service/CommentService.java
View file @
c9b7209f
...
@@ -153,7 +153,7 @@ public class CommentService {
...
@@ -153,7 +153,7 @@ public class CommentService {
//删除评论
//删除评论
@Transactional
@Transactional
public
void
delete
(
String
commentId
,
String
userId
)
{
public
CommentEntity
delete
(
String
commentId
,
String
userId
)
{
CommentEntity
commentEntity
=
this
.
queryByIdIncludeDelete
(
commentId
);
CommentEntity
commentEntity
=
this
.
queryByIdIncludeDelete
(
commentId
);
if
(
commentEntity
==
null
||
!
commentEntity
.
getAuthorId
().
equals
(
userId
))
{
if
(
commentEntity
==
null
||
!
commentEntity
.
getAuthorId
().
equals
(
userId
))
{
throw
new
BizException
(
"删除评论与用户不匹配,commentId:"
+
commentId
+
",userId:"
+
userId
);
throw
new
BizException
(
"删除评论与用户不匹配,commentId:"
+
commentId
+
",userId:"
+
userId
);
...
@@ -162,6 +162,7 @@ public class CommentService {
...
@@ -162,6 +162,7 @@ public class CommentService {
commentMapper
.
updateById
(
commentEntity
);
commentMapper
.
updateById
(
commentEntity
);
//失效缓存
//失效缓存
evictThemeCache
(
commentEntity
.
getThemeId
());
evictThemeCache
(
commentEntity
.
getThemeId
());
return
commentEntity
;
}
}
// 失效关联主题缓存
// 失效关联主题缓存
...
...
community-service/src/main/java/com/tanpu/community/service/ThemeService.java
View file @
c9b7209f
...
@@ -227,7 +227,7 @@ public class ThemeService {
...
@@ -227,7 +227,7 @@ public class ThemeService {
* @return
* @return
*/
*/
public
List
<
ThemeEntity
>
queryByUserIdsCreateDesc
(
List
<
String
>
userIds
,
Integer
pageStart
,
Integer
pageSize
,
Set
<
String
>
userPermitTopics
)
{
public
List
<
ThemeEntity
>
queryByUserIdsCreateDesc
(
List
<
String
>
userIds
,
Integer
pageStart
,
Integer
pageSize
,
Set
<
String
>
userPermitTopics
)
{
if
(
CollectionUtils
.
isEmpty
(
userIds
))
{
if
(
CollectionUtils
.
isEmpty
(
userIds
)
&&
CollectionUtils
.
isEmpty
(
userPermitTopics
)
)
{
return
Collections
.
emptyList
();
return
Collections
.
emptyList
();
}
}
userPermitTopics
.
remove
(
""
);
userPermitTopics
.
remove
(
""
);
...
...
community-service/src/main/resources/mapper/community/ThemeEntityMapper.xml
View file @
c9b7209f
...
@@ -64,16 +64,21 @@
...
@@ -64,16 +64,21 @@
select
select
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
from theme
from theme
where delete_tag=0 and ((author_id in
where delete_tag=0 and (
<if
test=
"authorIdCollection != null and authorIdCollection.size() > 0"
>
author_id in
<foreach
item=
"item"
index=
"index"
collection=
"authorIdCollection"
<foreach
item=
"item"
index=
"index"
collection=
"authorIdCollection"
open=
"("
separator=
","
close=
")"
>
open=
"("
separator=
","
close=
")"
>
#{item}
#{item}
</foreach>
</foreach>
and topic_id="") or topic_id in
</if>
<if
test=
"topicIdCollection != null and topicIdCollection.size() > 0"
>
or topic_id in
<foreach
item=
"item"
index=
"index"
collection=
"topicIdCollection"
<foreach
item=
"item"
index=
"index"
collection=
"topicIdCollection"
open=
"("
separator=
","
close=
")"
>
open=
"("
separator=
","
close=
")"
>
#{item}
#{item}
</foreach>
</foreach>
</if>
) order by create_time desc limit #{pageStart}, #{pageSize}
) order by create_time desc limit #{pageStart}, #{pageSize}
</select>
</select>
...
...
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