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
fd325b13
Commit
fd325b13
authored
Jul 23, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
正文关注状态错误fix
parent
9c7bc12b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
16 deletions
+27
-16
ThemeController.java
.../java/com/tanpu/community/controller/ThemeController.java
+1
-5
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+26
-11
No files found.
community-service/src/main/java/com/tanpu/community/controller/ThemeController.java
View file @
fd325b13
...
...
@@ -21,8 +21,6 @@ import org.springframework.web.bind.annotation.*;
import
javax.annotation.Resource
;
import
java.util.List
;
import
static
com
.
tanpu
.
community
.
api
.
constants
.
RedisKeyConstant
.
CACHE_THEME_ID
;
@RestController
@Slf4j
@RequestMapping
(
value
=
"/api/theme"
)
...
...
@@ -66,9 +64,7 @@ public class ThemeController {
@ResponseBody
public
CommonResp
<
ThemeQo
>
getThemeMainText
(
@RequestParam
String
themeId
)
{
String
userId
=
userHolder
.
getUserId
();
ThemeQo
themeQo
=
redisCache
.
getObject
(
StringUtils
.
joinWith
(
"_"
,
CACHE_THEME_ID
,
themeId
),
60
,
()
->
themeManager
.
getDetail
(
themeId
,
userId
),
ThemeQo
.
class
);
return
CommonResp
.
success
(
themeQo
);
return
CommonResp
.
success
(
themeManager
.
getDetail
(
themeId
,
userId
));
}
@AuthLogin
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
fd325b13
...
...
@@ -245,16 +245,27 @@ public class ThemeManager {
//进入详情
visitSummaryService
.
addPageView
(
userId
,
themeId
,
VisitTypeEnum
.
THEME_PAGE_VIEW
);
ThemeQo
themeQo
=
redisCache
.
getObject
(
StringUtils
.
joinWith
(
"_"
,
CACHE_THEME_ID
,
themeId
),
60
,
()
->
this
.
getDetailForCommon
(
themeId
),
ThemeQo
.
class
);
buildThemeExtraInfoByUser
(
userId
,
themeQo
);
return
themeQo
;
}
//正文通用信息,与用户无关,可使用缓存
private
ThemeQo
getDetailForCommon
(
String
themeId
)
{
ThemeEntity
themeEntity
=
themeService
.
queryByThemeId
(
themeId
);
if
(
themeEntity
==
null
)
{
throw
new
BizException
(
"找不到帖子id:"
+
themeId
);
}
ThemeQo
themeQo
=
ConvertUtil
.
themeEntityToQo
(
themeEntity
);
batchFeignCallService
.
getAttachDetail
(
themeQo
);
buildThemeQoExtraInfo
(
userId
,
themeQo
);
buildThemeQoExtraInfo
(
themeQo
);
return
themeQo
;
}
// 点赞/取消点赞
public
void
like
(
LikeThemeReq
req
,
String
userId
)
{
if
(
OperationTypeEnum
.
CONFIRM
.
getCode
().
equals
(
req
.
getType
()))
{
...
...
@@ -322,7 +333,8 @@ public class ThemeManager {
batchFeignCallService
.
getAttachDetailByBatch
(
themeQos
);
//其他信息
for
(
ThemeQo
themeQO
:
themeQos
)
{
buildThemeQoExtraInfo
(
userId
,
themeQO
);
buildThemeQoExtraInfo
(
themeQO
);
buildThemeExtraInfoByUser
(
userId
,
themeQO
);
}
return
themeQos
;
...
...
@@ -330,12 +342,22 @@ public class ThemeManager {
//组装主题详情
private
void
buildThemeQoExtraInfo
(
String
userId
,
ThemeQo
themeQo
)
{
private
void
buildThemeQoExtraInfo
(
ThemeQo
themeQo
)
{
String
themeId
=
themeQo
.
getThemeId
();
//封装转发对象
buildFormerTheme
(
themeQo
);
//点赞,收藏,转发
Integer
likeCount
=
collectionService
.
getCountByTypeAndId
(
themeId
,
CollectionTypeEnum
.
LIKE_THEME
);
Integer
commentCount
=
commentService
.
getCommentCountByThemeId
(
themeId
);
Integer
forwardCount
=
themeService
.
getForwardCountById
(
themeId
);
themeQo
.
setCommentCount
(
commentCount
);
themeQo
.
setLikeCount
(
likeCount
);
themeQo
.
setForwardCount
(
forwardCount
);
}
//组装和当前用户相关信息
private
void
buildThemeExtraInfoByUser
(
String
userId
,
ThemeQo
themeQo
){
String
themeId
=
themeQo
.
getThemeId
();
//是否关注作者
String
authorId
=
themeQo
.
getAuthorId
();
Set
<
String
>
fansSet
=
new
HashSet
<>(
followRelService
.
queryFansByFollowerId
(
userId
));
...
...
@@ -349,13 +371,6 @@ public class ThemeManager {
//是否收藏
CollectionEntity
collectionEntity
=
collectionService
.
getNotDeleteTargetCollection
(
themeId
,
userId
,
CollectionTypeEnum
.
COLLECT_THEME
);
themeQo
.
setHasCollect
(
collectionEntity
!=
null
);
//点赞,收藏,转发
Integer
likeCount
=
collectionService
.
getCountByTypeAndId
(
themeId
,
CollectionTypeEnum
.
LIKE_THEME
);
Integer
commentCount
=
commentService
.
getCommentCountByThemeId
(
themeId
);
Integer
forwardCount
=
themeService
.
getForwardCountById
(
themeId
);
themeQo
.
setCommentCount
(
commentCount
);
themeQo
.
setLikeCount
(
likeCount
);
themeQo
.
setForwardCount
(
forwardCount
);
}
...
...
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