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
35e14333
Commit
35e14333
authored
Feb 28, 2022
by
张辰
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v2.3.1' of
http://47.100.44.39:10001/tp-backend/tanpu-community
into v2.3.1
parents
b6111c09
f09ab871
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
8 deletions
+38
-8
TopicFollowQo.java
.../java/com/tanpu/community/api/beans/qo/TopicFollowQo.java
+3
-0
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+2
-2
TopicManager.java
...c/main/java/com/tanpu/community/manager/TopicManager.java
+1
-1
ThemeService.java
...c/main/java/com/tanpu/community/service/ThemeService.java
+7
-5
TopicService.java
...c/main/java/com/tanpu/community/service/TopicService.java
+25
-0
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicFollowQo.java
View file @
35e14333
...
@@ -45,6 +45,9 @@ public class TopicFollowQo {
...
@@ -45,6 +45,9 @@ public class TopicFollowQo {
@ApiModelProperty
(
value
=
"最近一条讨论"
)
@ApiModelProperty
(
value
=
"最近一条讨论"
)
public
String
lastTheme
;
public
String
lastTheme
;
@ApiModelProperty
(
value
=
"最近一条讨论发表时间"
)
public
long
lastThemeSecond
;
@ApiModelProperty
(
value
=
"最近一条讨论发表时间-格式化"
)
@ApiModelProperty
(
value
=
"最近一条讨论发表时间-格式化"
)
public
String
lastThemeTime
;
public
String
lastThemeTime
;
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
35e14333
...
@@ -528,10 +528,10 @@ public class ThemeManager {
...
@@ -528,10 +528,10 @@ public class ThemeManager {
fansList
.
add
(
userId
);
// 保证fansList不为空
fansList
.
add
(
userId
);
// 保证fansList不为空
// 权限控制,筛选出当前用户关注的话题
// 权限控制,筛选出当前用户关注的话题
Set
<
String
>
user
PermitTopics
=
topicService
.
getUserPermit
Topics
(
userId
);
Set
<
String
>
user
FollowTopics
=
topicService
.
getUserFollow
Topics
(
userId
);
// 查库
// 查库
themes
=
themeService
.
queryByUserIdsCreateDesc
(
fansList
,
pageStart
,
pageSize
,
user
Permit
Topics
);
themes
=
themeService
.
queryByUserIdsCreateDesc
(
fansList
,
pageStart
,
pageSize
,
user
Follow
Topics
);
if
(
CollectionUtils
.
isEmpty
(
excludeIds
)
&&
!
themes
.
isEmpty
())
{
if
(
CollectionUtils
.
isEmpty
(
excludeIds
)
&&
!
themes
.
isEmpty
())
{
// 说明是从头开始刷,则直接把最新的lastId放到redis中,保留一个月
// 说明是从头开始刷,则直接把最新的lastId放到redis中,保留一个月
...
...
community-service/src/main/java/com/tanpu/community/manager/TopicManager.java
View file @
35e14333
...
@@ -111,7 +111,7 @@ public class TopicManager {
...
@@ -111,7 +111,7 @@ public class TopicManager {
// 排序
// 排序
List
<
TopicFollowQo
>
res
=
topicFollowQos
.
stream
().
filter
(
o
->
o
.
checkTopicName
(
keyword
)).
sorted
(
Comparator
.
comparing
(
TopicFollowQo:
:
getSpecialPermission
,
Comparator
.
reverseOrder
()).
List
<
TopicFollowQo
>
res
=
topicFollowQos
.
stream
().
filter
(
o
->
o
.
checkTopicName
(
keyword
)).
sorted
(
Comparator
.
comparing
(
TopicFollowQo:
:
getSpecialPermission
,
Comparator
.
reverseOrder
()).
thenComparing
(
TopicFollowQo:
:
getLastTheme
Time
,
Comparator
.
nullsFirst
(
Stri
ng:
:
compareTo
).
reversed
()))
thenComparing
(
TopicFollowQo:
:
getLastTheme
Second
,
Comparator
.
nullsFirst
(
Lo
ng:
:
compareTo
).
reversed
()))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
return
res
;
return
res
;
...
...
community-service/src/main/java/com/tanpu/community/service/ThemeService.java
View file @
35e14333
...
@@ -31,6 +31,7 @@ import org.springframework.stereotype.Service;
...
@@ -31,6 +31,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.time.ZoneOffset
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -223,15 +224,15 @@ public class ThemeService {
...
@@ -223,15 +224,15 @@ public class ThemeService {
* @param userIds
* @param userIds
* @param pageStart
* @param pageStart
* @param pageSize
* @param pageSize
* @param user
Permit
Topics
* @param user
Follow
Topics
* @return
* @return
*/
*/
public
List
<
ThemeEntity
>
queryByUserIdsCreateDesc
(
List
<
String
>
userIds
,
Integer
pageStart
,
Integer
pageSize
,
Set
<
String
>
user
Permit
Topics
)
{
public
List
<
ThemeEntity
>
queryByUserIdsCreateDesc
(
List
<
String
>
userIds
,
Integer
pageStart
,
Integer
pageSize
,
Set
<
String
>
user
Follow
Topics
)
{
if
(
CollectionUtils
.
isEmpty
(
userIds
)
&&
CollectionUtils
.
isEmpty
(
user
Permit
Topics
))
{
if
(
CollectionUtils
.
isEmpty
(
userIds
)
&&
CollectionUtils
.
isEmpty
(
user
Follow
Topics
))
{
return
Collections
.
emptyList
();
return
Collections
.
emptyList
();
}
}
user
Permit
Topics
.
remove
(
""
);
user
Follow
Topics
.
remove
(
""
);
return
themeMapper
.
queryFollowList
(
userIds
,
user
Permit
Topics
,
pageStart
,
pageSize
);
return
themeMapper
.
queryFollowList
(
userIds
,
user
Follow
Topics
,
pageStart
,
pageSize
);
}
}
...
@@ -361,6 +362,7 @@ public class ThemeService {
...
@@ -361,6 +362,7 @@ public class ThemeService {
topic
.
setLastTheme
(
getUserName
(
themeQo
.
getAuthorId
())
+
":"
+
themeQo
.
content
.
get
(
0
).
getValue
());
topic
.
setLastTheme
(
getUserName
(
themeQo
.
getAuthorId
())
+
":"
+
themeQo
.
content
.
get
(
0
).
getValue
());
topic
.
setLastThemeTime
(
TimeUtils
.
formatTopicListTime
(
themeEntity
.
getUpdateTime
()));
topic
.
setLastThemeTime
(
TimeUtils
.
formatTopicListTime
(
themeEntity
.
getUpdateTime
()));
topic
.
setLastThemeSecond
(
themeEntity
.
getUpdateTime
().
toEpochSecond
(
ZoneOffset
.
of
(
"+8"
)));
}
}
...
...
community-service/src/main/java/com/tanpu/community/service/TopicService.java
View file @
35e14333
...
@@ -169,6 +169,11 @@ public class TopicService {
...
@@ -169,6 +169,11 @@ public class TopicService {
}
}
}
}
/**
* 逐个校验是否有权限
* @param content
* @param userId
*/
public
void
batchCheckPermission
(
List
<
TopicRankQo
>
content
,
String
userId
)
{
public
void
batchCheckPermission
(
List
<
TopicRankQo
>
content
,
String
userId
)
{
Set
<
String
>
userPermitTopics
=
getUserPermitTopics
(
userId
);
Set
<
String
>
userPermitTopics
=
getUserPermitTopics
(
userId
);
content
.
forEach
(
o
->
{
content
.
forEach
(
o
->
{
...
@@ -343,6 +348,11 @@ public class TopicService {
...
@@ -343,6 +348,11 @@ public class TopicService {
}
}
/**
* 获取用户有权限的话题(专属的+所有的公开话题)
* @param userId
* @return
*/
public
Set
<
String
>
getUserPermitTopics
(
String
userId
)
{
public
Set
<
String
>
getUserPermitTopics
(
String
userId
)
{
// 公开权限的话题
// 公开权限的话题
List
<
TopicEntity
>
openTopics
=
topicMapper
.
selectList
(
new
LambdaQueryWrapper
<
TopicEntity
>()
List
<
TopicEntity
>
openTopics
=
topicMapper
.
selectList
(
new
LambdaQueryWrapper
<
TopicEntity
>()
...
@@ -364,4 +374,19 @@ public class TopicService {
...
@@ -364,4 +374,19 @@ public class TopicService {
res
.
addAll
(
openTopicIds
);
res
.
addAll
(
openTopicIds
);
return
res
;
return
res
;
}
}
/**
* 获取用户关注的话题(专属的+关注的公开话题)
* @param userId
* @return
*/
public
Set
<
String
>
getUserFollowTopics
(
String
userId
)
{
if
(
StringUtils
.
isBlank
(
userId
))
{
return
new
HashSet
<>();
}
// 拥有权限的话题
List
<
String
>
followTopics
=
topicFollowRelMapper
.
selectTopicIdByUserId
(
userId
);
HashSet
<
String
>
res
=
new
HashSet
<>(
followTopics
);
return
res
;
}
}
}
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