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
7754ef0c
Commit
7754ef0c
authored
Jul 21, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
topic返回对象优化
parent
2a77678a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
33 deletions
+53
-33
ThemeContentQo.java
...java/com/tanpu/community/api/beans/qo/ThemeContentQo.java
+1
-1
RelTypeEnum.java
.../main/java/com/tanpu/community/api/enums/RelTypeEnum.java
+1
-1
TopicManager.java
...c/main/java/com/tanpu/community/manager/TopicManager.java
+8
-26
RankService.java
...rc/main/java/com/tanpu/community/service/RankService.java
+43
-5
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/qo/ThemeContentQo.java
View file @
7754ef0c
...
@@ -17,7 +17,7 @@ import java.util.List;
...
@@ -17,7 +17,7 @@ import java.util.List;
@NoArgsConstructor
@NoArgsConstructor
public
class
ThemeContentQo
{
public
class
ThemeContentQo
{
@ApiModelProperty
(
value
=
"RelTypeEnum类型,108:文本,88:产品 3:直播 6:短视频 303:新版课程-视频,新版课程-音频,109:单图(长文) 110:多图(讨论)"
)
@ApiModelProperty
(
value
=
"RelTypeEnum类型,108:文本,88:产品 3:直播 6:短视频 303:新版课程-视频,
304:
新版课程-音频,109:单图(长文) 110:多图(讨论)"
)
private
String
type
;
private
String
type
;
@ApiModelProperty
(
value
=
"文本的值是内容,附件的值为id"
)
@ApiModelProperty
(
value
=
"文本的值是内容,附件的值为id"
)
...
...
community-api/src/main/java/com/tanpu/community/api/enums/RelTypeEnum.java
View file @
7754ef0c
...
@@ -76,7 +76,7 @@ public enum RelTypeEnum {
...
@@ -76,7 +76,7 @@ public enum RelTypeEnum {
/**
/**
* 新版课程
* 新版课程
*/
*/
NEW_COURSE_SECTION_VIDEO
(
304
,
"新版课程 - 小节 - 视频"
,
30
3
),
NEW_COURSE_SECTION_VIDEO
(
304
,
"新版课程 - 小节 - 视频"
,
30
4
),
/**
/**
* 新版课程附件
* 新版课程附件
...
...
community-service/src/main/java/com/tanpu/community/manager/TopicManager.java
View file @
7754ef0c
...
@@ -4,13 +4,11 @@ import com.tanpu.common.exception.BizException;
...
@@ -4,13 +4,11 @@ import com.tanpu.common.exception.BizException;
import
com.tanpu.community.api.beans.qo.TopicRankQo
;
import
com.tanpu.community.api.beans.qo.TopicRankQo
;
import
com.tanpu.community.api.beans.req.page.Page
;
import
com.tanpu.community.api.beans.req.page.Page
;
import
com.tanpu.community.api.beans.req.topic.TopicSearchReq
;
import
com.tanpu.community.api.beans.req.topic.TopicSearchReq
;
import
com.tanpu.community.api.beans.vo.TopicDTO
;
import
com.tanpu.community.api.beans.vo.TopicDataAnalysDTO
;
import
com.tanpu.community.api.beans.vo.TopicDataAnalysDTO
;
import
com.tanpu.community.api.constants.RedisKeyConstant
;
import
com.tanpu.community.api.constants.RedisKeyConstant
;
import
com.tanpu.community.api.enums.CollectionTypeEnum
;
import
com.tanpu.community.api.enums.CollectionTypeEnum
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.service.*
;
import
com.tanpu.community.service.*
;
import
com.tanpu.community.util.ConvertUtil
;
import
com.tanpu.community.util.PageUtils
;
import
com.tanpu.community.util.PageUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -18,7 +16,6 @@ import org.springframework.stereotype.Service;
...
@@ -18,7 +16,6 @@ import org.springframework.stereotype.Service;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
@Service
@Service
public
class
TopicManager
{
public
class
TopicManager
{
...
@@ -46,44 +43,29 @@ public class TopicManager {
...
@@ -46,44 +43,29 @@ public class TopicManager {
//新增话题
//新增话题
public
void
insertTopic
(
String
topicTitle
,
String
userId
)
{
public
void
insertTopic
(
String
topicTitle
,
String
userId
)
{
if
(
topicService
.
queryByTitile
(
topicTitle
)
==
null
)
{
if
(
topicService
.
queryByTitile
(
topicTitle
)
==
null
)
{
t
opicService
.
addTopic
(
topicTitle
,
userId
);
t
hrow
new
BizException
(
"话题名称已存在:"
+
topicTitle
);
}
}
return
;
topicService
.
addTopic
(
topicTitle
,
userId
)
;
}
}
//
话题详情列表
//
首页-话题标签
public
List
<
Topic
DTO
>
getAllTopicDetail
()
{
public
List
<
Topic
RankQo
>
getTop4TopicTitles
()
{
return
ConvertUtil
.
topicEntitiesToDTOs
(
topicService
.
queryAll
()
);
return
rankService
.
getRankTopicListTop4
(
);
}
}
//话题
简介
列表
//话题
搜索
列表
public
Page
<
TopicRankQo
>
getAllTopicBriefInfo
(
TopicSearchReq
req
)
{
public
Page
<
TopicRankQo
>
getAllTopicBriefInfo
(
TopicSearchReq
req
)
{
if
(
rankService
.
rankTopicList
.
size
()==
0
){
return
PageUtils
.
page
(
req
.
getPage
(),
rankService
.
getRankTopicList
());
rankService
.
rankTopics
();
}
return
PageUtils
.
page
(
req
.
getPage
(),
rankService
.
rankTopicList
);
}
}
//话题详情页
//话题详情页
public
TopicRankQo
getDetail
(
String
topicId
)
{
public
TopicRankQo
getDetail
(
String
topicId
)
{
if
(
rankService
.
rankTopicList
.
size
()==
0
){
return
rankService
.
getTopicDetail
(
topicId
);
rankService
.
rankTopics
();
}
List
<
TopicRankQo
>
matchTopic
=
rankService
.
rankTopicList
.
stream
().
filter
(
o
->
o
.
getTopicId
().
equals
(
topicId
)).
limit
(
1
).
collect
(
Collectors
.
toList
());
matchTopic
.
add
(
new
TopicRankQo
());
return
matchTopic
.
get
(
0
);
}
}
public
List
<
TopicRankQo
>
getTop4TopicTitles
()
{
if
(
rankService
.
rankTopicList
.
size
()==
0
){
rankService
.
rankTopics
();
}
return
rankService
.
rankTopicListTop4
;
}
public
void
setTopTopic
(
String
topicId
,
boolean
setTop
)
{
public
void
setTopTopic
(
String
topicId
,
boolean
setTop
)
{
TopicEntity
topicEntity
=
topicService
.
queryById
(
topicId
);
TopicEntity
topicEntity
=
topicService
.
queryById
(
topicId
);
if
(
topicEntity
==
null
)
{
if
(
topicEntity
==
null
)
{
...
...
community-service/src/main/java/com/tanpu/community/service/RankService.java
View file @
7754ef0c
...
@@ -28,12 +28,15 @@ public class RankService {
...
@@ -28,12 +28,15 @@ public class RankService {
private
VisitSummaryService
visitSummaryService
;
private
VisitSummaryService
visitSummaryService
;
p
ublic
List
<
String
>
rankThemeList
=
new
ArrayList
<>();
p
rivate
List
<
String
>
rankThemeList
=
new
ArrayList
<>();
p
ublic
List
<
TopicRankQo
>
rankTopicList
=
new
ArrayList
<>();
p
rivate
List
<
TopicRankQo
>
rankTopicList
=
new
ArrayList
<>();
p
ublic
List
<
TopicRankQo
>
rankTopicListTop4
=
new
ArrayList
<>();
p
rivate
List
<
TopicRankQo
>
rankTopicListTop4
=
new
ArrayList
<>();
/**
* 计算主题热度排行
*/
public
void
rankThemes
()
{
public
void
rankThemes
()
{
List
<
ThemeEntity
>
themeEntities
=
themeService
.
queryAll
();
List
<
ThemeEntity
>
themeEntities
=
themeService
.
queryAll
();
List
<
ThemeAnalysDO
>
themeAnalysDOS
=
ConvertUtil
.
themeEntityToAnalysDOs
(
themeEntities
);
List
<
ThemeAnalysDO
>
themeAnalysDOS
=
ConvertUtil
.
themeEntityToAnalysDOs
(
themeEntities
);
...
@@ -84,12 +87,18 @@ public class RankService {
...
@@ -84,12 +87,18 @@ public class RankService {
Map
<
TopicRankQo
,
Integer
>
map
=
topicRankQos
.
stream
().
collect
(
Collectors
.
toMap
(
o
->
o
,
TopicRankQo:
:
getRank
));
Map
<
TopicRankQo
,
Integer
>
map
=
topicRankQos
.
stream
().
collect
(
Collectors
.
toMap
(
o
->
o
,
TopicRankQo:
:
getRank
));
List
<
TopicRankQo
>
rankList
=
map
.
entrySet
().
stream
().
sorted
(
Map
.
Entry
.
comparingByValue
(
Comparator
.
reverseOrder
())).
map
(
Map
.
Entry
::
getKey
).
collect
(
Collectors
.
toList
());
List
<
TopicRankQo
>
rankList
=
map
.
entrySet
().
stream
().
sorted
(
Map
.
Entry
.
comparingByValue
(
Comparator
.
reverseOrder
())).
map
(
Map
.
Entry
::
getKey
).
collect
(
Collectors
.
toList
());
rankList
.
get
(
0
).
setType
(
TopicStatusEnum
.
HOTTEST
.
getCode
());
rankList
.
get
(
0
).
setType
(
TopicStatusEnum
.
HOTTEST
.
getCode
());
rankTopicList
=
rankList
;
this
.
rankTopicList
=
rankList
;
rankTopicListTop4
=
rankList
.
stream
().
limit
(
4
).
collect
(
Collectors
.
toList
());
this
.
rankTopicListTop4
=
rankList
.
stream
().
limit
(
4
).
collect
(
Collectors
.
toList
());
return
;
return
;
}
}
/**
* 最新和热门主题集合
* @param hotCount
* @param newCount
* @return
*/
public
List
<
String
>
getHotAndNewThemes
(
Integer
hotCount
,
Integer
newCount
)
{
public
List
<
String
>
getHotAndNewThemes
(
Integer
hotCount
,
Integer
newCount
)
{
Set
<
String
>
hotThemeIds
=
this
.
rankThemeList
.
stream
().
limit
(
hotCount
).
collect
(
Collectors
.
toSet
());
Set
<
String
>
hotThemeIds
=
this
.
rankThemeList
.
stream
().
limit
(
hotCount
).
collect
(
Collectors
.
toSet
());
Set
<
String
>
newThemeIds
=
themeService
.
selectExcludeUser
(
null
,
null
,
newCount
)
Set
<
String
>
newThemeIds
=
themeService
.
selectExcludeUser
(
null
,
null
,
newCount
)
...
@@ -98,4 +107,33 @@ public class RankService {
...
@@ -98,4 +107,33 @@ public class RankService {
return
new
ArrayList
<>(
hotThemeIds
);
return
new
ArrayList
<>(
hotThemeIds
);
}
}
/**
* 话题详情
* @param topicId 话题Id
* @return
*/
public
TopicRankQo
getTopicDetail
(
String
topicId
){
if
(
this
.
rankTopicList
.
size
()==
0
){
rankTopics
();
}
List
<
TopicRankQo
>
matchTopic
=
this
.
rankTopicList
.
stream
().
filter
(
o
->
o
.
getTopicId
().
equals
(
topicId
)).
limit
(
1
).
collect
(
Collectors
.
toList
());
matchTopic
.
add
(
new
TopicRankQo
());
return
matchTopic
.
get
(
0
);
}
public
List
<
String
>
getRankThemeList
()
{
return
rankThemeList
;
}
public
List
<
TopicRankQo
>
getRankTopicList
()
{
if
(
this
.
rankTopicList
.
size
()==
0
){
this
.
rankTopics
();
}
return
rankTopicList
;
}
public
List
<
TopicRankQo
>
getRankTopicListTop4
()
{
return
rankTopicListTop4
;
}
}
}
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