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
436eb668
Commit
436eb668
authored
Jul 23, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
评论的主题+用户信息
parent
30450304
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
11 deletions
+27
-11
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+27
-11
No files found.
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
436eb668
...
@@ -4,15 +4,18 @@ import com.google.common.collect.Sets;
...
@@ -4,15 +4,18 @@ import com.google.common.collect.Sets;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.common.util.JsonUtil
;
import
com.tanpu.common.util.JsonUtil
;
import
com.tanpu.community.api.beans.qo.*
;
import
com.tanpu.community.api.beans.qo.ESThemeQo
;
import
com.tanpu.community.api.beans.qo.FormerThemeQo
;
import
com.tanpu.community.api.beans.qo.ThemeContentQo
;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
import
com.tanpu.community.api.beans.req.homepage.QueryRecordThemeReq
;
import
com.tanpu.community.api.beans.req.homepage.QueryRecordThemeReq
;
import
com.tanpu.community.api.beans.req.theme.*
;
import
com.tanpu.community.api.beans.req.theme.*
;
import
com.tanpu.community.api.beans.resp.CreateThemeResp
;
import
com.tanpu.community.api.beans.resp.CreateThemeResp
;
import
com.tanpu.community.api.beans.resp.ThemeFullSearchResp
;
import
com.tanpu.community.api.beans.resp.ThemeFullSearchResp
;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNew
;
import
com.tanpu.community.api.enums.*
;
import
com.tanpu.community.api.enums.*
;
import
com.tanpu.community.cache.RedisCache
;
import
com.tanpu.community.cache.RedisCache
;
import
com.tanpu.community.dao.entity.community.*
;
import
com.tanpu.community.dao.entity.community.*
;
import
com.tanpu.community.dao.entity.user.UserInfoEntity
;
import
com.tanpu.community.feign.fatools.FeignClientForFatools
;
import
com.tanpu.community.feign.fatools.FeignClientForFatools
;
import
com.tanpu.community.service.*
;
import
com.tanpu.community.service.*
;
import
com.tanpu.community.service.base.ESService
;
import
com.tanpu.community.service.base.ESService
;
...
@@ -33,8 +36,7 @@ import java.time.LocalDateTime;
...
@@ -33,8 +36,7 @@ import java.time.LocalDateTime;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
static
com
.
tanpu
.
community
.
api
.
constants
.
RedisKeyConstant
.
CACHE_FORMER_THEME_ID
;
import
static
com
.
tanpu
.
community
.
api
.
constants
.
RedisKeyConstant
.*;
import
static
com
.
tanpu
.
community
.
api
.
constants
.
RedisKeyConstant
.
CACHE_THEME_ID
;
@Slf4j
@Slf4j
@Service
@Service
...
@@ -248,9 +250,7 @@ public class ThemeManager {
...
@@ -248,9 +250,7 @@ public class ThemeManager {
private
void
buildThemeExtraInfoByUser
(
String
userId
,
ThemeQo
themeQo
)
{
private
void
buildThemeExtraInfoByUser
(
String
userId
,
ThemeQo
themeQo
)
{
String
themeId
=
themeQo
.
getThemeId
();
String
themeId
=
themeQo
.
getThemeId
();
//是否关注作者
//是否关注作者
String
authorId
=
themeQo
.
getAuthorId
();
themeQo
.
setFollow
(
followRelService
.
checkFollow
(
themeQo
.
getAuthorId
(),
userId
));
Set
<
String
>
fansSet
=
new
HashSet
<>(
followRelService
.
queryFansByFollowerId
(
userId
));
themeQo
.
setFollow
(
fansSet
.
contains
(
authorId
));
//是否点赞
//是否点赞
CollectionEntity
likeEntity
=
collectionService
.
getNotDeleteTargetCollection
(
themeId
,
userId
,
CollectionTypeEnum
.
LIKE_THEME
);
CollectionEntity
likeEntity
=
collectionService
.
getNotDeleteTargetCollection
(
themeId
,
userId
,
CollectionTypeEnum
.
LIKE_THEME
);
themeQo
.
setHasLiked
(
likeEntity
!=
null
);
themeQo
.
setHasLiked
(
likeEntity
!=
null
);
...
@@ -439,7 +439,8 @@ public class ThemeManager {
...
@@ -439,7 +439,8 @@ public class ThemeManager {
//评论列表
//评论列表
List
<
CommentEntity
>
commentEntities
=
commentService
.
queryThemesByUserId
(
req
.
getUserId
(),
req
.
getLastId
(),
req
.
getPageSize
());
List
<
CommentEntity
>
commentEntities
=
commentService
.
queryThemesByUserId
(
req
.
getUserId
(),
req
.
getLastId
(),
req
.
getPageSize
());
//当前用户信息
//当前用户信息
UserInfoEntity
userInfoEntity
=
userInfoService
.
queryUserById
(
req
.
getUserId
());
UserInfoNew
userInfo
=
redisCache
.
getObject
(
StringUtils
.
joinWith
(
CACGE_FEIGN_USER_INFO
,
req
.
getUserId
()),
60
*
10
,
()
->
this
.
getUserInfo
(
req
.
getUserId
())
,
UserInfoNew
.
class
);
Set
<
String
>
replyThemeIds
=
commentEntities
.
stream
().
map
(
CommentEntity:
:
getThemeId
).
collect
(
Collectors
.
toSet
());
Set
<
String
>
replyThemeIds
=
commentEntities
.
stream
().
map
(
CommentEntity:
:
getThemeId
).
collect
(
Collectors
.
toSet
());
if
(
CollectionUtils
.
isEmpty
(
replyThemeIds
))
{
if
(
CollectionUtils
.
isEmpty
(
replyThemeIds
))
{
return
commentThemeList
;
return
commentThemeList
;
...
@@ -464,13 +465,19 @@ public class ThemeManager {
...
@@ -464,13 +465,19 @@ public class ThemeManager {
FormerThemeQo
f
=
ConvertUtil
.
themeQo2FormerThemeQo
(
themeQo
);
FormerThemeQo
f
=
ConvertUtil
.
themeQo2FormerThemeQo
(
themeQo
);
//ThemeContentQo和原主题包装到FormerThemeQo中包装到ThemeQo中
//ThemeContentQo和原主题包装到FormerThemeQo中包装到ThemeQo中
ThemeQo
commentThemeQo
=
ThemeQo
.
builder
()
ThemeQo
commentThemeQo
=
ThemeQo
.
builder
()
.
authorId
(
userInfoEntity
.
getId
())
.
authorId
(
userInfo
.
getUserId
())
.
nickName
(
userInfoEntity
.
getUiUsernameMp
())
.
nickName
(
userInfo
.
getNickName
())
.
userImg
(
userInfoEntity
.
getUiHeadimgMp
())
.
userImg
(
userInfo
.
getHeadImageUrl
())
.
userType
(
userInfo
.
getUserType
())
.
levelGrade
(
userInfo
.
getLevelGrade
())
.
userInvestorType
(
userInfo
.
getUserInvestorType
())
.
belongUserOrgId
(
userInfo
.
getBelongUserOrgId
())
.
belongUserOrgName
(
userInfo
.
getBelongUserOrgName
())
.
content
(
Arrays
.
asList
(
commentContent
))
.
content
(
Arrays
.
asList
(
commentContent
))
.
formerTheme
(
f
)
.
formerTheme
(
f
)
.
commentId
(
commentEntity
.
getCommentId
())
.
commentId
(
commentEntity
.
getCommentId
())
.
themeType
(
ThemeTypeEnum
.
RES_COMMENT
.
getCode
())
.
themeType
(
ThemeTypeEnum
.
RES_COMMENT
.
getCode
())
.
follow
(
followRelService
.
checkFollow
(
themeQo
.
getAuthorId
(),
userId
))
.
build
();
.
build
();
commentThemeList
.
add
(
commentThemeQo
);
commentThemeList
.
add
(
commentThemeQo
);
...
@@ -478,4 +485,13 @@ public class ThemeManager {
...
@@ -478,4 +485,13 @@ public class ThemeManager {
return
commentThemeList
;
return
commentThemeList
;
}
}
private
UserInfoNew
getUserInfo
(
String
authorId
){
CommonResp
<
UserInfoNew
>
userInfoNewCommonResp
=
feignClientForFatools
.
queryUsersListNew
(
authorId
);
if
(
userInfoNewCommonResp
.
isNotSuccess
())
{
throw
new
BizException
(
"内部接口调用失败"
);
}
return
userInfoNewCommonResp
.
getData
();
}
}
}
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