Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beyond-clouds
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
段启岩
beyond-clouds
Commits
55b73c24
Commit
55b73c24
authored
Feb 12, 2020
by
段启岩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化用户dto命名
parent
55b2cf55
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
50 deletions
+40
-50
src/main/java/cn/meteor/beyondclouds/modules/search/service/impl/SearchServiceImpl.java
+0
-1
src/main/java/cn/meteor/beyondclouds/modules/user/api/UserApi.java
+7
-10
src/main/java/cn/meteor/beyondclouds/modules/user/dto/FollowUserDTO.java
+1
-1
src/main/java/cn/meteor/beyondclouds/modules/user/service/IUserFollowService.java
+3
-6
src/main/java/cn/meteor/beyondclouds/modules/user/service/IUserService.java
+0
-3
src/main/java/cn/meteor/beyondclouds/modules/user/service/impl/UserFollowServiceImpl.java
+29
-29
No files found.
src/main/java/cn/meteor/beyondclouds/modules/search/service/impl/SearchServiceImpl.java
View file @
55b73c24
...
...
@@ -23,7 +23,6 @@ import cn.meteor.beyondclouds.modules.search.service.ISearchService;
import
cn.meteor.beyondclouds.modules.topic.service.ITopicService
;
import
cn.meteor.beyondclouds.modules.user.dto.UserInfoDTO
;
import
cn.meteor.beyondclouds.modules.user.entity.User
;
import
cn.meteor.beyondclouds.modules.user.entity.UserStatistics
;
import
cn.meteor.beyondclouds.modules.user.exception.UserServiceException
;
import
cn.meteor.beyondclouds.modules.user.service.IUserService
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
...
...
src/main/java/cn/meteor/beyondclouds/modules/user/api/UserApi.java
View file @
55b73c24
...
...
@@ -9,12 +9,10 @@ import cn.meteor.beyondclouds.core.api.Response;
import
cn.meteor.beyondclouds.core.authentication.Subject
;
import
cn.meteor.beyondclouds.core.flow.AccessInfo
;
import
cn.meteor.beyondclouds.core.flow.ParamType
;
import
cn.meteor.beyondclouds.modules.user.dto.UserAuthDTO
;
import
cn.meteor.beyondclouds.modules.user.dto.UserInfoDTO
;
import
cn.meteor.beyondclouds.modules.user.dto.
UserInfoWithStatistics
DTO
;
import
cn.meteor.beyondclouds.modules.user.dto.
FollowUser
DTO
;
import
cn.meteor.beyondclouds.modules.user.entity.User
;
import
cn.meteor.beyondclouds.modules.user.entity.UserBlacklist
;
import
cn.meteor.beyondclouds.modules.user.entity.UserFollow
;
import
cn.meteor.beyondclouds.modules.user.entity.UserStatistics
;
import
cn.meteor.beyondclouds.modules.user.exception.UserServiceException
;
import
cn.meteor.beyondclouds.modules.user.form.*
;
...
...
@@ -33,7 +31,6 @@ import org.springframework.validation.BindingResult;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.Valid
;
import
java.util.List
;
/**
* @author meteor
...
...
@@ -299,10 +296,10 @@ public class UserApi {
@ApiOperation
((
"获取我的粉丝"
))
@GetMapping
(
"/my/fans"
)
public
Response
<
PageDTO
<
UserInfoWithStatistics
DTO
>>
myFans
(
@Valid
PageForm
pageForm
,
@CurrentSubject
Subject
subject
){
public
Response
<
PageDTO
<
FollowUser
DTO
>>
myFans
(
@Valid
PageForm
pageForm
,
@CurrentSubject
Subject
subject
){
// 根据userId获取粉丝并返回
PageDTO
<
UserInfoWithStatistics
DTO
>
fansPage
=
userFollowService
.
getFansPage
(
pageForm
.
getPage
(),
pageForm
.
getSize
(),
(
String
)
subject
.
getId
());
PageDTO
<
FollowUser
DTO
>
fansPage
=
userFollowService
.
getFansPage
(
pageForm
.
getPage
(),
pageForm
.
getSize
(),
(
String
)
subject
.
getId
());
return
Response
.
success
(
fansPage
);
}
...
...
@@ -310,10 +307,10 @@ public class UserApi {
@Anonymous
@ApiOperation
((
"获取他人粉丝"
))
@GetMapping
(
"/user/{userId}/fans"
)
public
Response
<
PageDTO
<
UserInfoWithStatistics
DTO
>>
otherFans
(
@Valid
PageForm
pageForm
,
@PathVariable
(
name
=
"userId"
)
String
userId
){
public
Response
<
PageDTO
<
FollowUser
DTO
>>
otherFans
(
@Valid
PageForm
pageForm
,
@PathVariable
(
name
=
"userId"
)
String
userId
){
// 根据userId获取粉丝并返回
PageDTO
<
UserInfoWithStatistics
DTO
>
fansPage
=
userFollowService
.
getFansPage
(
pageForm
.
getPage
(),
pageForm
.
getSize
(),
userId
);
PageDTO
<
FollowUser
DTO
>
fansPage
=
userFollowService
.
getFansPage
(
pageForm
.
getPage
(),
pageForm
.
getSize
(),
userId
);
return
Response
.
success
(
fansPage
);
}
...
...
@@ -323,14 +320,14 @@ public class UserApi {
public
Response
myFollower
(
@Valid
PageForm
pageForm
,
@CurrentSubject
Subject
subject
){
// 根据userId获取关注列表并返回
PageDTO
<
UserInfoWithStatistics
DTO
>
followedPage
=
userFollowService
.
getFollowedPage
(
pageForm
.
getPage
(),
pageForm
.
getSize
(),
String
.
valueOf
(
subject
.
getId
()));
PageDTO
<
FollowUser
DTO
>
followedPage
=
userFollowService
.
getFollowedPage
(
pageForm
.
getPage
(),
pageForm
.
getSize
(),
String
.
valueOf
(
subject
.
getId
()));
return
Response
.
success
(
followedPage
);
}
@Anonymous
@ApiOperation
((
"获取他人关注"
))
@GetMapping
(
"/user/{userId}/follower"
)
public
Response
<
PageDTO
<
UserInfoWithStatistics
DTO
>>
otherFollower
(
@Valid
PageForm
pageForm
,
@PathVariable
(
name
=
"userId"
)
String
userId
){
public
Response
<
PageDTO
<
FollowUser
DTO
>>
otherFollower
(
@Valid
PageForm
pageForm
,
@PathVariable
(
name
=
"userId"
)
String
userId
){
// 根据userId获取关注列表并返回
PageDTO
followedPage
=
userFollowService
.
getFollowedPage
(
pageForm
.
getPage
(),
pageForm
.
getSize
(),
userId
);
...
...
src/main/java/cn/meteor/beyondclouds/modules/user/dto/
UserInfoWithStatistics
DTO.java
→
src/main/java/cn/meteor/beyondclouds/modules/user/dto/
FollowUser
DTO.java
View file @
55b73c24
...
...
@@ -10,7 +10,7 @@ import java.util.Date;
* @author meteor
*/
@Data
public
class
UserInfoWithStatistics
DTO
{
public
class
FollowUser
DTO
{
private
String
userId
;
...
...
src/main/java/cn/meteor/beyondclouds/modules/user/service/IUserFollowService.java
View file @
55b73c24
package
cn
.
meteor
.
beyondclouds
.
modules
.
user
.
service
;
import
cn.meteor.beyondclouds.common.dto.PageDTO
;
import
cn.meteor.beyondclouds.modules.user.dto.
UserInfoWithStatistics
DTO
;
import
cn.meteor.beyondclouds.modules.user.dto.
FollowUser
DTO
;
import
cn.meteor.beyondclouds.modules.user.entity.UserFollow
;
import
cn.meteor.beyondclouds.modules.user.exception.UserServiceException
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
java.util.Set
;
/**
* @author 段启岩
...
...
@@ -41,7 +38,7 @@ public interface IUserFollowService extends IService<UserFollow> {
* @param userId
* @return
*/
PageDTO
<
UserInfoWithStatistics
DTO
>
getFansPage
(
Integer
pageNumber
,
Integer
pageSize
,
String
userId
);
PageDTO
<
FollowUser
DTO
>
getFansPage
(
Integer
pageNumber
,
Integer
pageSize
,
String
userId
);
/**
* 根据userId查询关注的用户
...
...
@@ -50,7 +47,7 @@ public interface IUserFollowService extends IService<UserFollow> {
* @param userId
* @return
*/
PageDTO
<
UserInfoWithStatistics
DTO
>
getFollowedPage
(
Integer
pageNumber
,
Integer
pageSize
,
String
userId
);
PageDTO
<
FollowUser
DTO
>
getFollowedPage
(
Integer
pageNumber
,
Integer
pageSize
,
String
userId
);
/**
* 判断当前用户有没有关注目标用户
...
...
src/main/java/cn/meteor/beyondclouds/modules/user/service/IUserService.java
View file @
55b73c24
package
cn
.
meteor
.
beyondclouds
.
modules
.
user
.
service
;
import
cn.meteor.beyondclouds.common.dto.QQAuthResultDTO
;
import
cn.meteor.beyondclouds.modules.user.dto.UserAuthDTO
;
import
cn.meteor.beyondclouds.modules.user.dto.UserInfoDTO
;
import
cn.meteor.beyondclouds.modules.user.entity.User
;
import
cn.meteor.beyondclouds.modules.user.entity.UserStatistics
;
import
cn.meteor.beyondclouds.modules.user.exception.UserServiceException
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
java.util.List
;
/**
* @author meteor
*/
...
...
src/main/java/cn/meteor/beyondclouds/modules/user/service/impl/UserFollowServiceImpl.java
View file @
55b73c24
...
...
@@ -7,7 +7,7 @@ import cn.meteor.beyondclouds.core.queue.message.DataItemChangeMessage;
import
cn.meteor.beyondclouds.core.queue.message.DataItemType
;
import
cn.meteor.beyondclouds.core.redis.RedisKey
;
import
cn.meteor.beyondclouds.modules.queue.service.IMessageQueueService
;
import
cn.meteor.beyondclouds.modules.user.dto.
UserInfoWithStatistics
DTO
;
import
cn.meteor.beyondclouds.modules.user.dto.
FollowUser
DTO
;
import
cn.meteor.beyondclouds.modules.user.entity.User
;
import
cn.meteor.beyondclouds.modules.user.entity.UserBlacklist
;
import
cn.meteor.beyondclouds.modules.user.entity.UserFollow
;
...
...
@@ -183,7 +183,7 @@ public class UserFollowServiceImpl extends ServiceImpl<UserFollowMapper, UserFol
* @return
*/
@Override
public
PageDTO
<
UserInfoWithStatistics
DTO
>
getFansPage
(
Integer
pageNumber
,
Integer
pageSize
,
String
userId
)
{
public
PageDTO
<
FollowUser
DTO
>
getFansPage
(
Integer
pageNumber
,
Integer
pageSize
,
String
userId
)
{
IPage
<
UserFollow
>
page
=
new
Page
<>(
pageNumber
,
pageSize
);
QueryWrapper
<
UserFollow
>
userFollowQueryWrapper
=
new
QueryWrapper
<>();
userFollowQueryWrapper
.
eq
(
"followed_id"
,
userId
);
...
...
@@ -192,7 +192,7 @@ public class UserFollowServiceImpl extends ServiceImpl<UserFollowMapper, UserFol
List
<
UserFollow
>
userFollowList
=
userFollowPage
.
getRecords
();
List
<
UserInfoWithStatisticsDTO
>
userInfoWithStatistics
DTOList
;
List
<
FollowUserDTO
>
followUser
DTOList
;
if
(!
CollectionUtils
.
isEmpty
(
userFollowList
))
{
// 取出我的粉丝的ID
List
<
String
>
fanUserIds
=
userFollowList
.
stream
()
...
...
@@ -209,31 +209,31 @@ public class UserFollowServiceImpl extends ServiceImpl<UserFollowMapper, UserFol
));
// 通过userFollowList构造userInfoWithStatisticsDTOList
userInfoWithStatistics
DTOList
=
userFollowList
.
stream
()
followUser
DTOList
=
userFollowList
.
stream
()
.
map
(
userFollow
->
{
UserInfoWithStatisticsDTO
userInfoWithStatisticsDTO
=
new
UserInfoWithStatistics
DTO
();
FollowUserDTO
followUserDTO
=
new
FollowUser
DTO
();
String
fansId
=
userFollow
.
getFollowerId
();
userInfoWithStatistics
DTO
.
setUserId
(
fansId
);
userInfoWithStatistics
DTO
.
setUserNick
(
userFollow
.
getFollowerNick
());
userInfoWithStatistics
DTO
.
setUserAvatar
(
userFollow
.
getFollowerAvatar
());
userInfoWithStatistics
DTO
.
setStatistics
(
userStatisticsMap
.
get
(
fansId
));
followUser
DTO
.
setUserId
(
fansId
);
followUser
DTO
.
setUserNick
(
userFollow
.
getFollowerNick
());
followUser
DTO
.
setUserAvatar
(
userFollow
.
getFollowerAvatar
());
followUser
DTO
.
setStatistics
(
userStatisticsMap
.
get
(
fansId
));
if
(
SubjectUtils
.
isAuthenticated
())
{
userInfoWithStatistics
DTO
.
setFollowedUser
(
hasFollowedUser
(
fansId
));
followUser
DTO
.
setFollowedUser
(
hasFollowedUser
(
fansId
));
}
else
{
userInfoWithStatistics
DTO
.
setFollowedUser
(
false
);
followUser
DTO
.
setFollowedUser
(
false
);
}
return
userInfoWithStatistics
DTO
;
return
followUser
DTO
;
}).
collect
(
Collectors
.
toList
());
}
else
{
userInfoWithStatistics
DTOList
=
List
.
of
();
followUser
DTOList
=
List
.
of
();
}
// 3.转换分页并返回
PageDTO
<
UserInfoWithStatistics
DTO
>
pageDTO
=
new
PageDTO
<>();
PageDTO
<
FollowUser
DTO
>
pageDTO
=
new
PageDTO
<>();
PageUtils
.
copyMeta
(
userFollowPage
,
pageDTO
);
pageDTO
.
setDataList
(
userInfoWithStatistics
DTOList
);
pageDTO
.
setDataList
(
followUser
DTOList
);
return
pageDTO
;
}
...
...
@@ -266,7 +266,7 @@ public class UserFollowServiceImpl extends ServiceImpl<UserFollowMapper, UserFol
* @return
*/
@Override
public
PageDTO
<
UserInfoWithStatistics
DTO
>
getFollowedPage
(
Integer
pageNumber
,
Integer
pageSize
,
String
userId
)
{
public
PageDTO
<
FollowUser
DTO
>
getFollowedPage
(
Integer
pageNumber
,
Integer
pageSize
,
String
userId
)
{
// 1.获取所有的关注
IPage
<
UserFollow
>
page
=
new
Page
<>(
pageNumber
,
pageSize
);
...
...
@@ -277,7 +277,7 @@ public class UserFollowServiceImpl extends ServiceImpl<UserFollowMapper, UserFol
List
<
UserFollow
>
userFollowList
=
userFollowPage
.
getRecords
();
// 2.查询关注的用户的统计信息并填充到userInfoWithStatisticsDTOList里面
List
<
UserInfoWithStatisticsDTO
>
userInfoWithStatistics
DTOList
;
List
<
FollowUserDTO
>
followUser
DTOList
;
if
(!
CollectionUtils
.
isEmpty
(
userFollowList
))
{
List
<
String
>
followedUserIds
=
userFollowList
.
stream
()
.
map
(
UserFollow:
:
getFollowedId
).
collect
(
Collectors
.
toList
());
...
...
@@ -288,31 +288,31 @@ public class UserFollowServiceImpl extends ServiceImpl<UserFollowMapper, UserFol
userStatistics
->
userStatistics
));
userInfoWithStatistics
DTOList
=
userFollowList
.
stream
()
followUser
DTOList
=
userFollowList
.
stream
()
.
map
(
userFollow
->
{
UserInfoWithStatisticsDTO
userInfoWithStatisticsDTO
=
new
UserInfoWithStatistics
DTO
();
FollowUserDTO
followUserDTO
=
new
FollowUser
DTO
();
String
followedId
=
userFollow
.
getFollowedId
();
userInfoWithStatistics
DTO
.
setUserId
(
followedId
);
userInfoWithStatistics
DTO
.
setUserNick
(
userFollow
.
getFollowedNick
());
userInfoWithStatistics
DTO
.
setUserAvatar
(
userFollow
.
getFollowedAvatar
());
userInfoWithStatistics
DTO
.
setStatistics
(
userStatisticsMap
.
get
(
followedId
));
followUser
DTO
.
setUserId
(
followedId
);
followUser
DTO
.
setUserNick
(
userFollow
.
getFollowedNick
());
followUser
DTO
.
setUserAvatar
(
userFollow
.
getFollowedAvatar
());
followUser
DTO
.
setStatistics
(
userStatisticsMap
.
get
(
followedId
));
if
(
SubjectUtils
.
isAuthenticated
())
{
userInfoWithStatistics
DTO
.
setFollowedUser
(
hasFollowedUser
(
followedId
));
followUser
DTO
.
setFollowedUser
(
hasFollowedUser
(
followedId
));
}
else
{
userInfoWithStatistics
DTO
.
setFollowedUser
(
false
);
followUser
DTO
.
setFollowedUser
(
false
);
}
return
userInfoWithStatistics
DTO
;
return
followUser
DTO
;
}).
collect
(
Collectors
.
toList
());
}
else
{
userInfoWithStatistics
DTOList
=
List
.
of
();
followUser
DTOList
=
List
.
of
();
}
// 3.转换分页并返回
PageDTO
<
UserInfoWithStatistics
DTO
>
pageDTO
=
new
PageDTO
<>();
PageDTO
<
FollowUser
DTO
>
pageDTO
=
new
PageDTO
<>();
PageUtils
.
copyMeta
(
userFollowPage
,
pageDTO
);
pageDTO
.
setDataList
(
userInfoWithStatistics
DTOList
);
pageDTO
.
setDataList
(
followUser
DTOList
);
return
pageDTO
;
}
...
...
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