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
8820293a
Commit
8820293a
authored
Jul 23, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
转发内容使用缓存
parent
fd325b13
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
2 deletions
+28
-2
RedisKeyConstant.java
...a/com/tanpu/community/api/constants/RedisKeyConstant.java
+2
-0
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+26
-2
No files found.
community-api/src/main/java/com/tanpu/community/api/constants/RedisKeyConstant.java
View file @
8820293a
...
@@ -37,6 +37,8 @@ public class RedisKeyConstant {
...
@@ -37,6 +37,8 @@ public class RedisKeyConstant {
public
static
final
String
CAHCE_COMMENT_ID
=
"CACHE_COMMENT_ID_"
;
public
static
final
String
CAHCE_COMMENT_ID
=
"CACHE_COMMENT_ID_"
;
// 主题本身
// 主题本身
public
static
final
String
CACHE_THEME_ID
=
"CACHE_THEME_ID_"
;
public
static
final
String
CACHE_THEME_ID
=
"CACHE_THEME_ID_"
;
// 转发主题本身
public
static
final
String
CACHE_FORMER_THEME_ID
=
"CACHE_FORMER_THEME_ID_"
;
public
static
final
String
THEME_VIEW_COUNT_
=
"THEME_VIEW_COUNT_"
;
public
static
final
String
THEME_VIEW_COUNT_
=
"THEME_VIEW_COUNT_"
;
public
static
final
String
THEME_LIKE_COUNT_
=
"THEME_LIKE_COUNT_"
;
public
static
final
String
THEME_LIKE_COUNT_
=
"THEME_LIKE_COUNT_"
;
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
8820293a
...
@@ -33,6 +33,7 @@ import java.time.LocalDateTime;
...
@@ -33,6 +33,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
.
CACHE_THEME_ID
;
import
static
com
.
tanpu
.
community
.
api
.
constants
.
RedisKeyConstant
.
CACHE_THEME_ID
;
@Slf4j
@Slf4j
...
@@ -259,8 +260,12 @@ public class ThemeManager {
...
@@ -259,8 +260,12 @@ public class ThemeManager {
throw
new
BizException
(
"找不到帖子id:"
+
themeId
);
throw
new
BizException
(
"找不到帖子id:"
+
themeId
);
}
}
ThemeQo
themeQo
=
ConvertUtil
.
themeEntityToQo
(
themeEntity
);
ThemeQo
themeQo
=
ConvertUtil
.
themeEntityToQo
(
themeEntity
);
//附件
batchFeignCallService
.
getAttachDetail
(
themeQo
);
batchFeignCallService
.
getAttachDetail
(
themeQo
);
//转发、收藏、点赞
buildThemeQoExtraInfo
(
themeQo
);
buildThemeQoExtraInfo
(
themeQo
);
return
themeQo
;
return
themeQo
;
}
}
...
@@ -341,11 +346,13 @@ public class ThemeManager {
...
@@ -341,11 +346,13 @@ public class ThemeManager {
}
}
//
组装主题详情
//
转发对象、点赞、收藏、转发数
private
void
buildThemeQoExtraInfo
(
ThemeQo
themeQo
)
{
private
void
buildThemeQoExtraInfo
(
ThemeQo
themeQo
)
{
String
themeId
=
themeQo
.
getThemeId
();
String
themeId
=
themeQo
.
getThemeId
();
//封装转发对象
//封装转发对象
buildFormerTheme
(
themeQo
);
FormerThemeQo
former
=
redisCache
.
getObject
(
StringUtils
.
joinWith
(
"_"
,
CACHE_FORMER_THEME_ID
,
themeId
),
60
,
()
->
this
.
getFormerTheme
(
themeQo
.
getFormerThemeId
()),
FormerThemeQo
.
class
);
themeQo
.
setFormerTheme
(
former
);
//点赞,收藏,转发
//点赞,收藏,转发
Integer
likeCount
=
collectionService
.
getCountByTypeAndId
(
themeId
,
CollectionTypeEnum
.
LIKE_THEME
);
Integer
likeCount
=
collectionService
.
getCountByTypeAndId
(
themeId
,
CollectionTypeEnum
.
LIKE_THEME
);
Integer
commentCount
=
commentService
.
getCommentCountByThemeId
(
themeId
);
Integer
commentCount
=
commentService
.
getCommentCountByThemeId
(
themeId
);
...
@@ -378,10 +385,13 @@ public class ThemeManager {
...
@@ -378,10 +385,13 @@ public class ThemeManager {
private
void
buildFormerTheme
(
ThemeQo
themeQo
)
{
private
void
buildFormerTheme
(
ThemeQo
themeQo
)
{
String
formerThemeId
=
themeQo
.
getFormerThemeId
();
String
formerThemeId
=
themeQo
.
getFormerThemeId
();
if
(
StringUtils
.
isNotEmpty
(
formerThemeId
))
{
if
(
StringUtils
.
isNotEmpty
(
formerThemeId
))
{
ThemeQo
formerTheme
=
ConvertUtil
.
themeEntityToQo
(
themeService
.
queryByThemeId
(
formerThemeId
));
ThemeQo
formerTheme
=
ConvertUtil
.
themeEntityToQo
(
themeService
.
queryByThemeId
(
formerThemeId
));
if
(
formerTheme
!=
null
)
{
if
(
formerTheme
!=
null
)
{
//单个查询详情
//单个查询详情
batchFeignCallService
.
getAttachDetail
(
formerTheme
);
batchFeignCallService
.
getAttachDetail
(
formerTheme
);
FormerThemeQo
f
=
ConvertUtil
.
themeQo2FormerThemeQo
(
formerTheme
);
FormerThemeQo
f
=
ConvertUtil
.
themeQo2FormerThemeQo
(
formerTheme
);
themeQo
.
setFormerTheme
(
f
);
themeQo
.
setFormerTheme
(
f
);
...
@@ -390,6 +400,20 @@ public class ThemeManager {
...
@@ -390,6 +400,20 @@ public class ThemeManager {
}
}
}
}
//返回被转发主题
private
FormerThemeQo
getFormerTheme
(
String
formerThemeId
)
{
if
(
StringUtils
.
isNotEmpty
(
formerThemeId
))
{
ThemeQo
formerTheme
=
ConvertUtil
.
themeEntityToQo
(
themeService
.
queryByThemeId
(
formerThemeId
));
if
(
formerTheme
!=
null
)
{
batchFeignCallService
.
getAttachDetail
(
formerTheme
);
FormerThemeQo
f
=
ConvertUtil
.
themeQo2FormerThemeQo
(
formerTheme
);
return
f
;
}
}
return
null
;
}
//逻辑删除
//逻辑删除
public
void
delete
(
String
themeId
)
{
public
void
delete
(
String
themeId
)
{
...
...
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