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
69087f35
Commit
69087f35
authored
Aug 12, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加评论返回
parent
fec67e58
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
22 deletions
+31
-22
CommentController.java
...ava/com/tanpu/community/controller/CommentController.java
+5
-6
CodeAutoGenerator.java
.../main/java/com/tanpu/community/dao/CodeAutoGenerator.java
+1
-1
CommentManager.java
...main/java/com/tanpu/community/manager/CommentManager.java
+25
-15
No files found.
community-service/src/main/java/com/tanpu/community/controller/CommentController.java
View file @
69087f35
...
...
@@ -36,10 +36,9 @@ public class CommentController {
@AuthLogin
@PostMapping
(
value
=
"/publishComment"
)
@ResponseBody
public
CommonResp
<
Void
>
publishCommet
(
@Validated
@RequestBody
CreateCommentReq
req
)
{
public
CommonResp
<
CommentQo
>
publishCommet
(
@Validated
@RequestBody
CreateCommentReq
req
)
{
String
userId
=
userHolder
.
getUserId
();
commentManager
.
comment
(
req
,
userId
);
return
CommonResp
.
success
();
return
CommonResp
.
success
(
commentManager
.
comment
(
req
,
userId
));
}
@ApiOperation
(
"评论列表"
)
...
...
@@ -68,7 +67,7 @@ public class CommentController {
@ResponseBody
public
CommonResp
<
Void
>
reportComment
(
@Validated
@RequestBody
ReportCommentReq
req
)
{
String
userId
=
userHolder
.
getUserId
();
commentManager
.
report
(
req
,
userId
);
commentManager
.
report
(
req
,
userId
);
return
CommonResp
.
success
();
}
...
...
@@ -76,9 +75,9 @@ public class CommentController {
@GetMapping
(
value
=
"/deleteComment"
)
@AuthLogin
@ResponseBody
public
CommonResp
<
Void
>
reportComment
(
@RequestParam
(
value
=
"commentId"
)
String
commentId
)
{
public
CommonResp
<
Void
>
reportComment
(
@RequestParam
(
value
=
"commentId"
)
String
commentId
)
{
String
userId
=
userHolder
.
getUserId
();
commentManager
.
delete
(
commentId
,
userId
);
commentManager
.
delete
(
commentId
,
userId
);
return
CommonResp
.
success
();
}
}
community-service/src/main/java/com/tanpu/community/dao/CodeAutoGenerator.java
View file @
69087f35
...
...
@@ -23,7 +23,7 @@ public class CodeAutoGenerator {
String
mysqlPassword
=
"@imeng123"
;
String
jdbcUrl
=
"jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_community"
;
// String[] tables = new String[]{"theme"};
String
[]
tables
=
new
String
[]{
"
visit_log
"
};
String
[]
tables
=
new
String
[]{
"
message_queue
"
};
String
basePackage
=
"com.tanpu.community"
;
String
mapperPackage
=
"dao.mapper.community"
;
String
entityPackage
=
"dao.entity.community"
;
...
...
community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
View file @
69087f35
...
...
@@ -51,7 +51,7 @@ public class CommentManager {
// 评论(对主题)
// 发表评论(对主题)
public
void
comment
(
CreateCommentReq
req
,
String
userId
)
{
public
CommentQo
comment
(
CreateCommentReq
req
,
String
userId
)
{
if
(
StringUtils
.
isEmpty
(
req
.
getComment
()))
{
throw
new
IllegalArgumentException
(
"评论内容不能为空"
);
...
...
@@ -70,6 +70,9 @@ public class CommentManager {
.
build
();
commentService
.
insertComment
(
commentEntity
);
CommentQo
commentQo
=
ConvertUtil
.
commentEntity2Qo
(
commentEntity
);
buildUserInfo
(
commentQo
);
return
commentQo
;
}
// 查询评论
...
...
@@ -81,20 +84,9 @@ public class CommentManager {
Set
<
String
>
likeCommentList
=
collectionService
.
getSetByUser
(
userId
,
CollectionTypeEnum
.
LIKE_COMMENT
);
for
(
CommentQo
commentQo
:
commentQos
)
{
//查询用户信息
String
authorId
=
commentQo
.
getAuthorId
();
UserInfoResp
userInfo
=
redisCache
.
getObject
(
StringUtils
.
joinWith
(
"_"
,
CACHE_FEIGN_USER_INFO
,
authorId
),
60
,
()
->
this
.
getUserInfo
(
authorId
)
,
UserInfoResp
.
class
);
if
(
userInfo
!=
null
)
{
commentQo
.
setUserImg
(
userInfo
.
getHeadImageUrl
());
commentQo
.
setNickName
(
userInfo
.
getNickName
());
commentQo
.
setUserType
(
userInfo
.
getUserType
());
commentQo
.
setLevelGrade
(
userInfo
.
getLevelGrade
());
commentQo
.
setUserInvestorType
(
userInfo
.
getUserInvestorType
());
commentQo
.
setBelongUserOrgId
(
userInfo
.
getBelongUserOrgId
());
commentQo
.
setBelongUserOrgName
(
userInfo
.
getBelongUserOrgName
());
}
//是否点赞及点赞数
// 封装用户信息
buildUserInfo
(
commentQo
);
// 是否点赞及点赞数
String
commentId
=
commentQo
.
getCommentId
();
commentQo
.
setHasLiked
(
likeCommentList
.
contains
(
commentId
));
Integer
countByTypeAndId
=
collectionService
.
getCountByTypeAndId
(
commentId
,
CollectionTypeEnum
.
LIKE_COMMENT
);
...
...
@@ -107,6 +99,24 @@ public class CommentManager {
.
collect
(
Collectors
.
toList
());
}
private
void
buildUserInfo
(
CommentQo
commentQo
)
{
String
authorId
=
commentQo
.
getAuthorId
();
UserInfoResp
userInfo
=
redisCache
.
getObject
(
StringUtils
.
joinWith
(
"_"
,
CACHE_FEIGN_USER_INFO
,
authorId
),
60
,
()
->
this
.
getUserInfo
(
authorId
)
,
UserInfoResp
.
class
);
if
(
userInfo
!=
null
)
{
commentQo
.
setUserImg
(
userInfo
.
getHeadImageUrl
());
commentQo
.
setNickName
(
userInfo
.
getNickName
());
commentQo
.
setUserType
(
userInfo
.
getUserType
());
commentQo
.
setLevelGrade
(
userInfo
.
getLevelGrade
());
commentQo
.
setUserInvestorType
(
userInfo
.
getUserInvestorType
());
commentQo
.
setBelongUserOrgId
(
userInfo
.
getBelongUserOrgId
());
commentQo
.
setBelongUserOrgName
(
userInfo
.
getBelongUserOrgName
());
}
commentQo
.
setHasLiked
(
false
);
commentQo
.
setLikeCount
(
0
);
}
private
UserInfoResp
getUserInfo
(
String
authorId
){
CommonResp
<
UserInfoResp
>
userInfoNewCommonResp
=
feignClientForFatools
.
queryUserInfoNew
(
authorId
);
if
(
userInfoNewCommonResp
.
isNotSuccess
())
{
...
...
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