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
5609bb9d
Commit
5609bb9d
authored
Dec 10, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
转赞评批量查询
parent
4a3fa523
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
8 deletions
+34
-8
CourseSimpleResp.java
...community/api/beans/vo/feign/course/CourseSimpleResp.java
+3
-0
TimesCountEntity.java
...anpu/community/dao/entity/community/TimesCountEntity.java
+1
-1
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+30
-7
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/vo/feign/course/CourseSimpleResp.java
View file @
5609bb9d
...
...
@@ -49,4 +49,7 @@ public class CourseSimpleResp {
@ApiModelProperty
(
"状态 0:待上架 1:上架 2:下架"
)
private
Integer
status
;
@ApiModelProperty
(
"付费模式 1:免费 2:积分 3:现金"
)
private
Integer
modal
;
}
community-service/src/main/java/com/tanpu/community/dao/entity/community/TimesCountEntity.java
View file @
5609bb9d
...
...
@@ -11,6 +11,6 @@ public class TimesCountEntity {
@ApiModelProperty
(
value
=
"次数"
)
private
Integer
times
;
@ApiModelProperty
(
value
=
"
目标
id"
)
@ApiModelProperty
(
value
=
"
统计对象
id"
)
private
String
id
;
}
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
5609bb9d
...
...
@@ -555,11 +555,12 @@ public class ThemeManager {
List
<
ThemeQo
>
themeQos
=
ConvertUtil
.
themeEntitiesToDTOs
(
themeEntities
);
// 批量查询附件detail
batchFeignCallService
.
getAttachDetailByBatch
(
themeQos
);
//其他信息
for
(
ThemeQo
themeQO
:
themeQos
)
{
// 通用信息
buildThemeQoExtraInfo
(
themeQO
);
// 转赞评
batchBuildThemeCountInfo
(
themeQos
);
// 转发对象
for
(
ThemeQo
themeQO
:
themeQos
)
{
buildThemeForwardObj
(
themeQO
);
}
// 和用户相关信息
if
(
StringUtils
.
isNotEmpty
(
userId
))
{
...
...
@@ -568,15 +569,19 @@ public class ThemeManager {
return
themeQos
;
}
// 转发对象
、点赞、收藏、转发数
private
void
buildTheme
QoExtraInfo
(
ThemeQo
themeQo
)
{
// 转发对象
private
void
buildTheme
ForwardObj
(
ThemeQo
themeQo
)
{
String
themeId
=
themeQo
.
getThemeId
();
// 封装转发对象
FormerThemeQo
former
=
redisCache
.
getObject
(
StringUtils
.
joinWith
(
"_"
,
CACHE_FORWARD_THEME_ID
,
themeQo
.
getFormerThemeId
()),
60
,
()
->
this
.
getFormerTheme
(
themeQo
.
getFormerThemeId
()),
FormerThemeQo
.
class
);
themeQo
.
setFormerTheme
(
former
);
}
// 单个查询 点赞、收藏、转发数
private
void
buildThemeCountInfo
(
ThemeQo
themeQo
)
{
String
themeId
=
themeQo
.
getThemeId
();
// 点赞,收藏,转发
Integer
likeCount
=
redisCache
.
getObject
(
StringUtils
.
joinWith
(
"_"
,
THEME_LIKE_COUNT
,
themeId
),
60
,
()
->
collectionService
.
getCountByTypeAndId
(
themeId
,
CollectionTypeEnum
.
LIKE_THEME
),
Integer
.
class
);
...
...
@@ -586,11 +591,28 @@ public class ThemeManager {
Integer
forwardCount
=
redisCache
.
getObject
(
StringUtils
.
joinWith
(
"_"
,
THEME_FORWARD_COUNT
,
themeId
),
60
,
()
->
themeService
.
getForwardCountById
(
themeId
),
Integer
.
class
);
themeQo
.
setCommentCount
(
commentCount
);
themeQo
.
setLikeCount
(
likeCount
);
themeQo
.
setForwardCount
(
forwardCount
);
}
// 批量-点赞、收藏、转发数
private
void
batchBuildThemeCountInfo
(
List
<
ThemeQo
>
themeQos
)
{
List
<
String
>
themeIds
=
themeQos
.
stream
().
map
(
ThemeQo:
:
getThemeId
).
collect
(
Collectors
.
toList
());
// 点赞,收藏,转发
Map
<
String
,
Integer
>
likeCountMap
=
collectionService
.
getCountMapByType
(
themeIds
,
CollectionTypeEnum
.
LIKE_THEME
);
Map
<
String
,
Integer
>
commentCountMap
=
commentService
.
getCountMapByThemeIds
(
themeIds
);
Map
<
String
,
Integer
>
forwardCountMap
=
themeService
.
getForwardCountMap
(
themeIds
);
themeQos
.
stream
().
forEach
(
o
->{
o
.
setCommentCount
(
commentCountMap
.
getOrDefault
(
o
.
getThemeId
(),
0
));
o
.
setLikeCount
(
likeCountMap
.
getOrDefault
(
o
.
getThemeId
(),
0
));
o
.
setForwardCount
(
forwardCountMap
.
getOrDefault
(
o
.
getThemeId
(),
0
));
});
}
// 组装和当前用户相关信息(单个查询)
private
void
buildThemeExtraInfoByUser
(
String
userId
,
ThemeQo
themeQo
)
{
String
themeId
=
themeQo
.
getThemeId
();
...
...
@@ -688,7 +710,8 @@ public class ThemeManager {
batchFeignCallService
.
getAttachDetail
(
themeQo
);
//转发、收藏、点赞
buildThemeQoExtraInfo
(
themeQo
);
buildThemeForwardObj
(
themeQo
);
buildThemeCountInfo
(
themeQo
);
// 添加用户相关信息
if
(
StringUtils
.
isNotEmpty
(
userId
))
{
...
...
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