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
87da0782
Commit
87da0782
authored
Jul 29, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除主题评论
parent
9b9d7302
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
6 deletions
+36
-6
CommentController.java
...ava/com/tanpu/community/controller/CommentController.java
+10
-0
CommentManager.java
...main/java/com/tanpu/community/manager/CommentManager.java
+6
-0
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+2
-2
CommentService.java
...main/java/com/tanpu/community/service/CommentService.java
+14
-0
ThemeService.java
...c/main/java/com/tanpu/community/service/ThemeService.java
+3
-3
application-test.yml
community-service/src/main/resources/application-test.yml
+1
-1
No files found.
community-service/src/main/java/com/tanpu/community/controller/CommentController.java
View file @
87da0782
...
@@ -71,4 +71,14 @@ public class CommentController {
...
@@ -71,4 +71,14 @@ public class CommentController {
commentManager
.
report
(
req
,
userId
);
commentManager
.
report
(
req
,
userId
);
return
CommonResp
.
success
();
return
CommonResp
.
success
();
}
}
@ApiOperation
(
"删除评论"
)
@GetMapping
(
value
=
"/deleteComment"
)
@AuthLogin
@ResponseBody
public
CommonResp
<
Void
>
reportComment
(
@RequestParam
(
value
=
"commentId"
)
String
commentId
)
{
String
userId
=
userHolder
.
getUserId
();
commentManager
.
delete
(
commentId
,
userId
);
return
CommonResp
.
success
();
}
}
}
community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
View file @
87da0782
...
@@ -124,4 +124,10 @@ public class CommentManager {
...
@@ -124,4 +124,10 @@ public class CommentManager {
CommentEntity
commentEntity
=
commentService
.
queryByCommentId
(
req
.
getCommentId
());
CommentEntity
commentEntity
=
commentService
.
queryByCommentId
(
req
.
getCommentId
());
reportLogService
.
insert
(
ReportTypeEnum
.
COMMENT
,
userId
,
req
.
getCommentId
(),
commentEntity
.
getAuthorId
(),
req
.
getReason
());
reportLogService
.
insert
(
ReportTypeEnum
.
COMMENT
,
userId
,
req
.
getCommentId
(),
commentEntity
.
getAuthorId
(),
req
.
getReason
());
}
}
//删除评论
public
void
delete
(
String
commentId
,
String
userId
)
{
commentService
.
delete
(
commentId
,
userId
);
}
}
}
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
87da0782
...
@@ -415,9 +415,9 @@ public class ThemeManager {
...
@@ -415,9 +415,9 @@ public class ThemeManager {
}
}
//
逻辑删除主题 TODO
//
逻辑删除主题,校验用户
public
void
delete
(
String
themeId
,
String
userId
)
{
public
void
delete
(
String
themeId
,
String
userId
)
{
themeService
.
deleteById
(
themeId
);
themeService
.
deleteById
(
themeId
,
userId
);
}
}
...
...
community-service/src/main/java/com/tanpu/community/service/CommentService.java
View file @
87da0782
...
@@ -124,4 +124,18 @@ public class CommentService {
...
@@ -124,4 +124,18 @@ public class CommentService {
commentMapper
.
updateById
(
commentEntity
);
commentMapper
.
updateById
(
commentEntity
);
redisCache
.
evict
(
StringUtils
.
joinWith
(
"_"
,
CAHCE_COMMENT_ID
,
commentId
));
redisCache
.
evict
(
StringUtils
.
joinWith
(
"_"
,
CAHCE_COMMENT_ID
,
commentId
));
}
}
//删除评论
@Transactional
public
void
delete
(
String
commentId
,
String
userId
)
{
CommentEntity
commentEntity
=
this
.
queryByCommentId
(
commentId
);
if
(
commentEntity
==
null
||
!
commentEntity
.
getAuthorId
().
equals
(
userId
)){
throw
new
BizException
(
"删除评论与用户不匹配,commentId:"
+
commentId
+
",userId:"
+
userId
);
}
commentEntity
.
setDeleteTag
(
DeleteTagEnum
.
DELETED
.
getCode
());
commentMapper
.
updateById
(
commentEntity
);
//删除主题的评论列表缓存
redisCache
.
evict
(
StringUtils
.
joinWith
(
"_"
,
CAHCE_COMMENT_ID
,
commentEntity
.
getThemeId
()));
}
}
}
community-service/src/main/java/com/tanpu/community/service/ThemeService.java
View file @
87da0782
...
@@ -263,11 +263,11 @@ public class ThemeService {
...
@@ -263,11 +263,11 @@ public class ThemeService {
}
}
@Transactional
@Transactional
public
void
deleteById
(
String
themeId
)
{
public
void
deleteById
(
String
themeId
,
String
userId
)
{
ThemeEntity
themeEntity
=
themeMapper
.
selectOne
(
new
LambdaQueryWrapper
<
ThemeEntity
>()
ThemeEntity
themeEntity
=
themeMapper
.
selectOne
(
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
eq
(
ThemeEntity:
:
getThemeId
,
themeId
));
.
eq
(
ThemeEntity:
:
getThemeId
,
themeId
));
if
(
themeEntity
==
null
)
{
if
(
themeEntity
==
null
||
!
themeEntity
.
getAuthorId
().
equals
(
userId
)
)
{
throw
new
BizException
(
"主题
未找到,id:"
+
theme
Id
);
throw
new
BizException
(
"主题
与用户不匹配,id:"
+
themeId
+
",userId"
+
user
Id
);
}
}
themeEntity
.
setDeleteTag
(
DeleteTagEnum
.
DELETED
.
getCode
());
themeEntity
.
setDeleteTag
(
DeleteTagEnum
.
DELETED
.
getCode
());
themeMapper
.
updateById
(
themeEntity
);
themeMapper
.
updateById
(
themeEntity
);
...
...
community-service/src/main/resources/application-test.yml
View file @
87da0782
...
@@ -8,7 +8,7 @@ apollo.bootstrap.enabled: true
...
@@ -8,7 +8,7 @@ apollo.bootstrap.enabled: true
# namespaces: application.yml
# namespaces: application.yml
server
:
server
:
port
:
80
6
0
port
:
80
8
0
servlet
:
servlet
:
context-path
:
/community
context-path
:
/community
...
...
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