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
0eb0dfd2
Commit
0eb0dfd2
authored
Aug 11, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
话题排序
parent
6ac3f3bc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
TopicRankQo.java
...in/java/com/tanpu/community/api/beans/qo/TopicRankQo.java
+5
-0
RankService.java
...rc/main/java/com/tanpu/community/service/RankService.java
+14
-2
ConvertUtil.java
...e/src/main/java/com/tanpu/community/util/ConvertUtil.java
+2
-2
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicRankQo.java
View file @
0eb0dfd2
package
com
.
tanpu
.
community
.
api
.
beans
.
qo
;
package
com
.
tanpu
.
community
.
api
.
beans
.
qo
;
import
com.tanpu.biz.common.enums.community.TopicStatusEnum
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
...
@@ -41,4 +42,8 @@ public class TopicRankQo {
...
@@ -41,4 +42,8 @@ public class TopicRankQo {
private
Integer
minutesTillNow
;
private
Integer
minutesTillNow
;
private
Double
score
;
private
Double
score
;
public
boolean
judgeNewTopic
(){
return
TopicStatusEnum
.
NEWEST
.
getCode
().
equals
(
type
);
}
}
}
community-service/src/main/java/com/tanpu/community/service/RankService.java
View file @
0eb0dfd2
...
@@ -190,9 +190,21 @@ public class RankService {
...
@@ -190,9 +190,21 @@ public class RankService {
.
sorted
(
Map
.
Entry
.
comparingByValue
(
Comparator
.
reverseOrder
()))
.
sorted
(
Map
.
Entry
.
comparingByValue
(
Comparator
.
reverseOrder
()))
.
map
(
Map
.
Entry
::
getKey
)
.
map
(
Map
.
Entry
::
getKey
)
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
// 非“新”话题才能添加“热”标签
if
(!
TopicStatusEnum
.
NEWEST
.
getCode
().
equals
(
rankList
.
get
(
0
).
getType
()))
{
rankList
.
get
(
0
).
setType
(
TopicStatusEnum
.
HOTTEST
.
getCode
());
rankList
.
get
(
0
).
setType
(
TopicStatusEnum
.
HOTTEST
.
getCode
());
}
this
.
rankTopicList
=
rankList
;
this
.
rankTopicList
=
rankList
;
this
.
rankTopicListTop4
=
rankList
.
stream
().
limit
(
4
).
collect
(
Collectors
.
toList
());
// 首页推荐话题
List
<
TopicRankQo
>
newest2Topic
=
rankList
.
stream
().
filter
(
TopicRankQo:
:
judgeNewTopic
).
limit
(
2
).
collect
(
Collectors
.
toList
());
List
<
TopicRankQo
>
top4Topic
=
rankList
.
stream
()
.
limit
(
6
)
.
filter
(
o
->
!
newest2Topic
.
contains
(
o
))
.
limit
(
4
-
newest2Topic
.
size
())
.
collect
(
Collectors
.
toList
());
top4Topic
.
addAll
(
newest2Topic
);
this
.
rankTopicListTop4
=
top4Topic
;
//落库
//落库
rankLogService
.
logTopicRank
(
rankList
,
start
,
TimeUtils
.
calMillisTillNow
(
start
));
rankLogService
.
logTopicRank
(
rankList
,
start
,
TimeUtils
.
calMillisTillNow
(
start
));
...
...
community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java
View file @
0eb0dfd2
...
@@ -101,8 +101,8 @@ public class ConvertUtil {
...
@@ -101,8 +101,8 @@ public class ConvertUtil {
public
static
TopicRankQo
topicEntityToHotQo
(
TopicEntity
topicEntity
)
{
public
static
TopicRankQo
topicEntityToHotQo
(
TopicEntity
topicEntity
)
{
TopicRankQo
topicRankQo
=
new
TopicRankQo
();
TopicRankQo
topicRankQo
=
new
TopicRankQo
();
BeanUtils
.
copyProperties
(
topicEntity
,
topicRankQo
);
BeanUtils
.
copyProperties
(
topicEntity
,
topicRankQo
);
//
2
小时内发帖,添加新话题标签
//
24
小时内发帖,添加新话题标签
if
(
TimeUtils
.
calMinuteTillNow
(
topicEntity
.
getCreateTime
())
<
120
)
{
if
(
TimeUtils
.
calMinuteTillNow
(
topicEntity
.
getCreateTime
())
<
60
*
24
)
{
topicRankQo
.
setType
(
TopicStatusEnum
.
NEWEST
.
getCode
());
topicRankQo
.
setType
(
TopicStatusEnum
.
NEWEST
.
getCode
());
}
}
topicRankQo
.
setMinutesTillNow
((
int
)
TimeUtils
.
calMinuteTillNow
(
topicEntity
.
getCreateTime
()));
topicRankQo
.
setMinutesTillNow
((
int
)
TimeUtils
.
calMinuteTillNow
(
topicEntity
.
getCreateTime
()));
...
...
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