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
656e98ec
Commit
656e98ec
authored
Jul 16, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
关注列表
parent
80f73371
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
11 deletions
+20
-11
Page.java
...ain/java/com/tanpu/community/api/beans/req/page/Page.java
+7
-2
HomePageManager.java
...ain/java/com/tanpu/community/manager/HomePageManager.java
+9
-7
PageUtils.java
...ice/src/main/java/com/tanpu/community/util/PageUtils.java
+4
-2
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/req/page/Page.java
View file @
656e98ec
package
com
.
tanpu
.
community
.
api
.
beans
.
req
.
page
;
import
com.github.pagehelper.PageHelper
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
...
...
@@ -9,7 +8,6 @@ import java.util.List;
@Data
@Builder
@AllArgsConstructor
public
class
Page
<
T
>
{
private
Integer
pageNum
;
...
...
@@ -94,6 +92,13 @@ public class Page<T> {
}
}
public
Page
(
Integer
pageNum
,
Integer
pageSize
,
Long
totalSize
,
Integer
totalPages
,
List
<
T
>
content
)
{
this
.
pageNum
=
pageNum
;
this
.
pageSize
=
pageSize
;
this
.
totalSize
=
totalSize
;
this
.
totalPages
=
totalPages
;
this
.
content
=
content
;
}
public
Page
()
{
}
...
...
community-service/src/main/java/com/tanpu/community/manager/HomePageManager.java
View file @
656e98ec
...
...
@@ -11,12 +11,11 @@ import com.tanpu.community.service.FollowRelService;
import
com.tanpu.community.service.UserInfoService
;
import
com.tanpu.community.util.ConvertUtil
;
import
com.tanpu.community.util.PageUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Service
...
...
@@ -34,15 +33,18 @@ public class HomePageManager {
public
Page
<
FollowQo
>
queryFollow
(
QueryFollowReq
req
,
String
userId
)
{
List
<
String
>
userIds
=
QueryFollowTypeEnum
.
QUERY_FANS
.
getCode
().
equals
(
req
.
getQueryType
())
?
followRelService
.
queryFansByIdolId
(
req
.
getUserId
())
:
followRelService
.
queryFansByFollowerId
(
req
.
getUserId
());
List
<
UserInfoEntity
>
userInfos
=
userInfoService
.
queryUserByIds
(
userIds
);
List
<
FollowQo
>
collect
=
userInfos
.
stream
().
map
(
ConvertUtil:
:
homePageEntity2FollowQo
).
collect
(
Collectors
.
toList
());
List
<
FollowQo
>
followQos
=
judgeFollowed
(
collect
,
userId
);
List
<
FollowQo
>
followQos
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
userIds
))
{
List
<
UserInfoEntity
>
userInfos
=
userInfoService
.
queryUserByIds
(
userIds
);
List
<
FollowQo
>
collect
=
userInfos
.
stream
().
map
(
ConvertUtil:
:
homePageEntity2FollowQo
).
collect
(
Collectors
.
toList
());
followQos
=
judgeFollowed
(
collect
,
userId
);
}
//分页
return
PageUtils
.
page
(
req
.
getPage
(),
followQos
);
}
//判断返回列表中的用户是否被当前用户关注
public
List
<
FollowQo
>
judgeFollowed
(
List
<
FollowQo
>
followQos
,
String
followerId
)
{
Set
<
String
>
idolSet
=
new
HashSet
<>(
followRelService
.
queryFansByFollowerId
(
followerId
));
...
...
community-service/src/main/java/com/tanpu/community/util/PageUtils.java
View file @
656e98ec
...
...
@@ -14,11 +14,13 @@ import java.util.List;
public
class
PageUtils
{
public
static
<
T
>
Page
<
T
>
page
(
Pageable
pageable
,
List
<
T
>
list
)
{
if
(
CollectionUtils
.
isEmpty
(
list
))
{
if
(
pageable
==
null
){
return
new
Page
<
T
>(
1
,
0
,
(
long
)
list
.
size
(),
1
,
list
);
}
return
new
Page
<>(
pageable
,
0L
,
new
ArrayList
<>());
}
else
{
if
(
pageable
==
null
){
Pageable
p
=
new
Pageable
(
1
,
list
.
size
());
return
new
Page
<
T
>(
p
,
(
long
)
list
.
size
(),
list
);
return
new
Page
<
T
>(
1
,
list
.
size
(),
(
long
)
list
.
size
(),
1
,
list
);
}
// 记录总数
...
...
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