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
3314de2c
Commit
3314de2c
authored
Sep 24, 2021
by
王亚雷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
游客权限
parent
6b638eac
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
22 deletions
+32
-22
CommentController.java
...ava/com/tanpu/community/controller/CommentController.java
+6
-3
HomePageController.java
...va/com/tanpu/community/controller/HomePageController.java
+4
-6
CommentManager.java
...main/java/com/tanpu/community/manager/CommentManager.java
+7
-1
HomePageManager.java
...ain/java/com/tanpu/community/manager/HomePageManager.java
+12
-10
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+3
-2
No files found.
community-service/src/main/java/com/tanpu/community/controller/CommentController.java
View file @
3314de2c
...
@@ -11,6 +11,7 @@ import com.tanpu.community.api.beans.req.comment.QueryCommentReq;
...
@@ -11,6 +11,7 @@ import com.tanpu.community.api.beans.req.comment.QueryCommentReq;
import
com.tanpu.community.api.beans.req.comment.ReportCommentReq
;
import
com.tanpu.community.api.beans.req.comment.ReportCommentReq
;
import
com.tanpu.community.api.beans.req.page.Page
;
import
com.tanpu.community.api.beans.req.page.Page
;
import
com.tanpu.community.manager.CommentManager
;
import
com.tanpu.community.manager.CommentManager
;
import
com.tanpu.community.util.HttpServletHelper
;
import
com.tanpu.community.util.PageUtils
;
import
com.tanpu.community.util.PageUtils
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -32,6 +33,9 @@ public class CommentController {
...
@@ -32,6 +33,9 @@ public class CommentController {
@Resource
@Resource
private
UserHolder
userHolder
;
private
UserHolder
userHolder
;
@Resource
HttpServletHelper
httpServletHelper
;
@ApiOperation
(
"发表评论"
)
@ApiOperation
(
"发表评论"
)
@AuthLogin
@AuthLogin
@PostMapping
(
value
=
"/publishComment"
)
@PostMapping
(
value
=
"/publishComment"
)
...
@@ -42,12 +46,11 @@ public class CommentController {
...
@@ -42,12 +46,11 @@ public class CommentController {
}
}
@ApiOperation
(
"评论列表"
)
@ApiOperation
(
"评论列表"
)
@AuthLogin
@PostMapping
(
value
=
"/queryComment"
)
@PostMapping
(
value
=
"/queryComment"
)
@ResponseBody
@ResponseBody
public
CommonResp
<
Page
<
CommentQo
>>
queryComment
(
@Validated
@RequestBody
QueryCommentReq
req
)
{
public
CommonResp
<
Page
<
CommentQo
>>
queryComment
(
@Validated
@RequestBody
QueryCommentReq
req
)
{
String
userId
=
userHolder
.
ge
tUserId
();
String
selfUserId
=
httpServletHelper
.
getCurren
tUserId
();
List
<
CommentQo
>
result
=
commentManager
.
queryComments
(
req
.
getThemeId
(),
u
serId
);
List
<
CommentQo
>
result
=
commentManager
.
queryComments
(
req
.
getThemeId
(),
selfU
serId
);
return
CommonResp
.
success
(
PageUtils
.
page
(
req
.
getPage
(),
result
));
return
CommonResp
.
success
(
PageUtils
.
page
(
req
.
getPage
(),
result
));
}
}
...
...
community-service/src/main/java/com/tanpu/community/controller/HomePageController.java
View file @
3314de2c
...
@@ -76,10 +76,9 @@ public class HomePageController {
...
@@ -76,10 +76,9 @@ public class HomePageController {
@PostMapping
(
value
=
"/followList"
)
@PostMapping
(
value
=
"/followList"
)
@ApiOperation
(
"查询关注/粉丝列表"
)
@ApiOperation
(
"查询关注/粉丝列表"
)
@ResponseBody
@ResponseBody
@AuthLogin
public
CommonResp
<
Page
<
FollowQo
>>
queryFollowList
(
@RequestBody
QueryFollowReq
req
)
{
public
CommonResp
<
Page
<
FollowQo
>>
queryFollowList
(
@RequestBody
QueryFollowReq
req
)
{
String
userId
=
userHolder
.
ge
tUserId
();
String
selfUserId
=
httpServletHelper
.
getCurren
tUserId
();
return
CommonResp
.
success
(
homePageManager
.
queryFollow
(
req
,
u
serId
));
return
CommonResp
.
success
(
homePageManager
.
queryFollow
(
req
,
selfU
serId
));
}
}
@PostMapping
(
value
=
"/addIdol"
)
@PostMapping
(
value
=
"/addIdol"
)
...
@@ -95,10 +94,9 @@ public class HomePageController {
...
@@ -95,10 +94,9 @@ public class HomePageController {
@PostMapping
(
value
=
"/themeList"
)
@PostMapping
(
value
=
"/themeList"
)
@ApiOperation
(
"用户的帖子列表"
)
@ApiOperation
(
"用户的帖子列表"
)
@ResponseBody
@ResponseBody
@AuthLogin
public
CommonResp
<
List
<
ThemeQo
>>
likeList
(
@Validated
@RequestBody
QueryRecordThemeReq
req
)
{
public
CommonResp
<
List
<
ThemeQo
>>
likeList
(
@Validated
@RequestBody
QueryRecordThemeReq
req
)
{
String
userId
=
userHolder
.
ge
tUserId
();
String
selfUserId
=
httpServletHelper
.
getCurren
tUserId
();
return
CommonResp
.
success
(
themeManager
.
queryThemesByUser
(
req
,
u
serId
));
return
CommonResp
.
success
(
themeManager
.
queryThemesByUser
(
req
,
selfU
serId
));
}
}
}
}
community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
View file @
3314de2c
package
com
.
tanpu
.
community
.
manager
;
package
com
.
tanpu
.
community
.
manager
;
import
com.google.common.collect.Sets
;
import
com.tanpu.biz.common.enums.community.CollectionTypeEnum
;
import
com.tanpu.biz.common.enums.community.CollectionTypeEnum
;
import
com.tanpu.biz.common.enums.community.CommentTypeEnum
;
import
com.tanpu.biz.common.enums.community.CommentTypeEnum
;
import
com.tanpu.biz.common.enums.community.ReportTypeEnum
;
import
com.tanpu.biz.common.enums.community.ReportTypeEnum
;
...
@@ -116,7 +117,12 @@ public class CommentManager {
...
@@ -116,7 +117,12 @@ public class CommentManager {
List
<
CommentEntity
>
commentEntities
=
commentService
.
selectByThemeId
(
themeId
);
List
<
CommentEntity
>
commentEntities
=
commentService
.
selectByThemeId
(
themeId
);
List
<
CommentQo
>
commentQos
=
ConvertUtil
.
commentEntity2Qos
(
commentEntities
);
List
<
CommentQo
>
commentQos
=
ConvertUtil
.
commentEntity2Qos
(
commentEntities
);
Set
<
String
>
likeCommentList
=
collectionService
.
getSetByUser
(
userId
,
CollectionTypeEnum
.
LIKE_COMMENT
);
Set
<
String
>
likeCommentList
;
if
(
StringUtils
.
isNotEmpty
(
userId
))
{
likeCommentList
=
collectionService
.
getSetByUser
(
userId
,
CollectionTypeEnum
.
LIKE_COMMENT
);
}
else
{
likeCommentList
=
Sets
.
newHashSetWithExpectedSize
(
0
);
}
for
(
CommentQo
commentQo
:
commentQos
)
{
for
(
CommentQo
commentQo
:
commentQos
)
{
// 封装用户信息
// 封装用户信息
...
...
community-service/src/main/java/com/tanpu/community/manager/HomePageManager.java
View file @
3314de2c
package
com
.
tanpu
.
community
.
manager
;
package
com
.
tanpu
.
community
.
manager
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.google.common.collect.Lists
;
import
com.tanpu.biz.common.enums.user.UserLevelEnum
;
import
com.tanpu.biz.common.enums.user.UserLevelEnum
;
import
com.tanpu.biz.common.enums.user.UserTypeEnum
;
import
com.tanpu.biz.common.enums.user.UserTypeEnum
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.api.CommonResp
;
...
@@ -46,6 +47,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -46,6 +47,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.validation.constraints.NotEmpty
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -257,26 +259,26 @@ public class HomePageManager {
...
@@ -257,26 +259,26 @@ public class HomePageManager {
Page
<
String
>
userIdsPage
=
QueryFollowTypeEnum
.
QUERY_FANS
.
getCode
().
equals
(
req
.
getQueryType
())
?
Page
<
String
>
userIdsPage
=
QueryFollowTypeEnum
.
QUERY_FANS
.
getCode
().
equals
(
req
.
getQueryType
())
?
followRelService
.
queryFansByIdolId
(
req
.
userId
,
pageNumber
,
pageSize
)
followRelService
.
queryFansByIdolId
(
req
.
userId
,
pageNumber
,
pageSize
)
:
followRelService
.
queryIdolsByFansId
(
req
.
userId
,
pageNumber
,
pageSize
);
:
followRelService
.
queryIdolsByFansId
(
req
.
userId
,
pageNumber
,
pageSize
);
List
<
FollowQo
>
followQos
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isEmpty
(
userIdsPage
.
getContent
()))
{
if
(!
CollectionUtils
.
isEmpty
(
userIdsPage
.
getContent
()))
{
return
PageUtils
.
page
(
userIdsPage
,
Lists
.
newArrayListWithCapacity
(
0
));
List
<
UserInfoResp
>
userInfoNews
=
feignClientForFatools
.
queryUserListNew
(
userIdsPage
.
getContent
());
}
List
<
FollowQo
>
collect
=
userInfoNews
.
stream
().
map
(
ConvertUtil:
:
userInfoNew2FollowQo
).
collect
(
Collectors
.
toList
());
List
<
UserInfoResp
>
userInfoNews
=
feignClientForFatools
.
queryUserListNew
(
userIdsPage
.
getContent
());
followQos
=
judgeFollowed
(
collect
,
userId
);
List
<
FollowQo
>
followQos
=
userInfoNews
.
stream
().
map
(
ConvertUtil:
:
userInfoNew2FollowQo
).
collect
(
Collectors
.
toList
());
if
(
StringUtils
.
isNotEmpty
(
userId
))
{
judgeFollowed
(
followQos
,
userId
);
}
}
return
PageUtils
.
page
(
userIdsPage
,
followQos
);
return
PageUtils
.
page
(
userIdsPage
,
followQos
);
}
}
//判断返回列表中的用户是否被当前用户关注
//判断返回列表中的用户是否被当前用户关注
public
List
<
FollowQo
>
judgeFollowed
(
List
<
FollowQo
>
followQos
,
String
followerId
)
{
public
void
judgeFollowed
(
List
<
FollowQo
>
followQos
,
@NotEmpty
String
followerId
)
{
Set
<
String
>
idolSet
=
new
HashSet
<>(
followRelService
.
queryIdolsByFansId
(
followerId
));
Set
<
String
>
idolSet
=
new
HashSet
<>(
followRelService
.
queryIdolsByFansId
(
followerId
));
return
followQos
.
stream
().
map
(
o
->
{
followQos
.
stream
().
peek
(
o
->
{
if
(
idolSet
.
contains
(
o
.
getUserId
()))
{
if
(
idolSet
.
contains
(
o
.
getUserId
()))
{
o
.
setFollowed
(
true
);
o
.
setFollowed
(
true
);
}
}
return
o
;
});
}).
collect
(
Collectors
.
toList
());
}
}
public
void
addFollowRel
(
FollowRelReq
req
,
String
followerId
)
{
public
void
addFollowRel
(
FollowRelReq
req
,
String
followerId
)
{
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
3314de2c
...
@@ -653,7 +653,7 @@ public class ThemeManager {
...
@@ -653,7 +653,7 @@ public class ThemeManager {
}
}
List
<
ThemeQo
>
themeQos
=
convertEntityToQo
(
themeEntities
,
userId
);
List
<
ThemeQo
>
themeQos
=
convertEntityToQo
(
themeEntities
,
userId
);
if
(
userId
.
equals
(
req
.
getUserId
()))
{
if
(
StringUtils
.
equals
(
userId
,
req
.
getUserId
()))
{
//如果用户是查询自己的帖子,需要实时查询用户自己的个人信息,防止数据不一致(非收藏类型)
//如果用户是查询自己的帖子,需要实时查询用户自己的个人信息,防止数据不一致(非收藏类型)
CommonResp
<
UserInfoResp
>
userInfoNewCommonResp
=
feignClientForFatools
.
queryUserInfoNew
(
userId
);
CommonResp
<
UserInfoResp
>
userInfoNewCommonResp
=
feignClientForFatools
.
queryUserInfoNew
(
userId
);
if
(
userInfoNewCommonResp
.
isNotSuccess
())
{
if
(
userInfoNewCommonResp
.
isNotSuccess
())
{
...
@@ -913,7 +913,8 @@ public class ThemeManager {
...
@@ -913,7 +913,8 @@ public class ThemeManager {
.
content
(
Collections
.
singletonList
(
commentContent
))
.
content
(
Collections
.
singletonList
(
commentContent
))
.
commentId
(
commentEntity
.
getCommentId
())
.
commentId
(
commentEntity
.
getCommentId
())
.
themeType
(
ThemeTypeEnum
.
RES_COMMENT
.
getCode
())
.
themeType
(
ThemeTypeEnum
.
RES_COMMENT
.
getCode
())
.
follow
(
followRelService
.
checkFollow
(
userId
,
userId
))
// 回复列表不需要关注按钮
// .follow(followRelService.checkFollow(userInfo.getUserId(), userId))
.
upToNowTime
(
TimeUtils
.
calUpToNowTime
(
commentEntity
.
getCreateTime
()))
.
upToNowTime
(
TimeUtils
.
calUpToNowTime
(
commentEntity
.
getCreateTime
()))
.
build
();
.
build
();
...
...
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