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
94cd9e42
Commit
94cd9e42
authored
Feb 12, 2020
by
段启岩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取他人基本信息接口添加是否关注该用户的字段
parent
9e3871e5
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
87 additions
and
4 deletions
+87
-4
src/main/java/cn/meteor/beyondclouds/modules/user/api/UserApi.java
+8
-3
src/main/java/cn/meteor/beyondclouds/modules/user/listener/UserStatisticsListener.java
+2
-0
src/main/java/cn/meteor/beyondclouds/modules/user/service/IUserFollowService.java
+7
-0
src/main/java/cn/meteor/beyondclouds/modules/user/service/impl/UserFollowServiceImpl.java
+16
-0
src/main/java/cn/meteor/beyondclouds/modules/user/vo/UserInfoWithFollowedVO.java
+53
-0
src/main/resources/application.yml
+1
-1
No files found.
src/main/java/cn/meteor/beyondclouds/modules/user/api/UserApi.java
View file @
94cd9e42
...
...
@@ -19,6 +19,7 @@ import cn.meteor.beyondclouds.modules.user.form.*;
import
cn.meteor.beyondclouds.modules.user.service.IUserBlacklistService
;
import
cn.meteor.beyondclouds.modules.user.service.IUserFollowService
;
import
cn.meteor.beyondclouds.modules.user.service.IUserService
;
import
cn.meteor.beyondclouds.modules.user.vo.UserInfoWithFollowedVO
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -190,8 +191,8 @@ public class UserApi {
@Anonymous
@ApiOperation
((
"获取他人基本信息"
))
@GetMapping
(
"/user/{userId}/baseinfo"
)
public
Response
<
UserInfo
DT
O
>
updateOtherBaseInfo
(
@PathVariable
(
name
=
"userId"
)
String
userId
,
@CollectAccessInfo
(
type
=
ParamType
.
USER_STATISTICS
,
paramName
=
"userId"
)
AccessInfo
accessInfo
){
public
Response
<
UserInfo
WithFollowedV
O
>
updateOtherBaseInfo
(
@PathVariable
(
name
=
"userId"
)
String
userId
,
@CollectAccessInfo
(
type
=
ParamType
.
USER_STATISTICS
,
paramName
=
"userId"
)
AccessInfo
accessInfo
){
boolean
updateVisited
=
false
;
if
(
null
!=
accessInfo
.
getFieldVisitCount
()
&&
accessInfo
.
getFieldVisitCount
()
==
0
)
{
...
...
@@ -208,8 +209,12 @@ public class UserApi {
userInfoDTO
.
setQqNumber
(
null
);
userInfoDTO
.
setWxNumber
(
null
);
UserInfoWithFollowedVO
userInfoWithFollowedVO
=
new
UserInfoWithFollowedVO
();
BeanUtils
.
copyProperties
(
userInfoDTO
,
userInfoWithFollowedVO
);
Boolean
followedUser
=
userFollowService
.
hasFollowedUser
(
userId
,
userInfoDTO
.
getUserId
());
userInfoWithFollowedVO
.
setFollowedUser
(
followedUser
);
// 返回结果
return
Response
.
success
(
userInfo
DT
O
);
return
Response
.
success
(
userInfo
WithFollowedV
O
);
}
catch
(
UserServiceException
e
)
{
e
.
printStackTrace
();
return
Response
.
error
(
e
);
...
...
src/main/java/cn/meteor/beyondclouds/modules/user/listener/UserStatisticsListener.java
View file @
94cd9e42
...
...
@@ -105,6 +105,7 @@ public class UserStatisticsListener implements DataItemChangeListener {
// 更新被关注用户的粉丝量
QueryWrapper
<
UserFollow
>
followedUserFansNumQueryWrapper
=
new
QueryWrapper
<>();
followedUserFansNumQueryWrapper
.
eq
(
"followed_id"
,
userFollow
.
getFollowedId
());
followedUserFansNumQueryWrapper
.
eq
(
"follow_status"
,
0
);
long
followedUserFansNum
=
userFollowService
.
count
(
followedUserFansNumQueryWrapper
);
updateUserStatisticValue
(
userFollow
.
getFollowedId
(),
"fans_num"
,
followedUserFansNum
);
// 发送被关注用户统计信息修改的消息
...
...
@@ -114,6 +115,7 @@ public class UserStatisticsListener implements DataItemChangeListener {
// 更新关注者的关注量
QueryWrapper
<
UserFollow
>
followerUserFollowedNumQueryWrapper
=
new
QueryWrapper
<>();
followerUserFollowedNumQueryWrapper
.
eq
(
"follower_id"
,
userFollow
.
getFollowerId
());
followerUserFollowedNumQueryWrapper
.
eq
(
"follow_status"
,
0
);
long
followerUserFollowedNum
=
userFollowService
.
count
(
followerUserFollowedNumQueryWrapper
);
updateUserStatisticValue
(
userFollow
.
getFollowerId
(),
"followed_num"
,
followerUserFollowedNum
);
// 发送关注者统计信息修改的消息
...
...
src/main/java/cn/meteor/beyondclouds/modules/user/service/IUserFollowService.java
View file @
94cd9e42
...
...
@@ -58,4 +58,11 @@ public interface IUserFollowService extends IService<UserFollow> {
*/
Set
<
String
>
getCurrentUserFollowedUserIds
(
String
userId
);
/**
* 查看当前用户是否关注了目标用户
* @param currentUserId
* @param userId
* @return
*/
Boolean
hasFollowedUser
(
String
currentUserId
,
String
userId
);
}
src/main/java/cn/meteor/beyondclouds/modules/user/service/impl/UserFollowServiceImpl.java
View file @
94cd9e42
...
...
@@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.util.Set
;
...
...
@@ -193,6 +194,21 @@ public class UserFollowServiceImpl extends ServiceImpl<UserFollowMapper, UserFol
public
Set
<
String
>
getCurrentUserFollowedUserIds
(
String
userId
)
{
return
redisHelper
.
setGet
(
RedisKey
.
USER_FOLLOWED
(
userId
));
}
@Override
public
Boolean
hasFollowedUser
(
String
currentUserId
,
String
userId
)
{
// 如果是自己,直接返回true
if
(
currentUserId
.
equals
(
userId
))
{
return
true
;
}
Set
<
String
>
currentUserFollowedUserIds
=
getCurrentUserFollowedUserIds
(
currentUserId
);
if
(!
CollectionUtils
.
isEmpty
(
currentUserFollowedUserIds
))
{
return
currentUserFollowedUserIds
.
contains
(
userId
);
}
return
null
;
}
}
src/main/java/cn/meteor/beyondclouds/modules/user/vo/UserInfoWithFollowedVO.java
0 → 100644
View file @
94cd9e42
package
cn
.
meteor
.
beyondclouds
.
modules
.
user
.
vo
;
import
cn.meteor.beyondclouds.modules.user.entity.UserStatistics
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
/**
* 用户信息
* @author 段启岩
*/
@Data
public
class
UserInfoWithFollowedVO
{
private
String
userId
;
@ApiModelProperty
(
value
=
"用户昵称"
)
private
String
nickName
;
@ApiModelProperty
(
value
=
"用户头像"
)
private
String
userAvatar
;
@ApiModelProperty
(
value
=
"性别"
)
private
Integer
gender
;
@ApiModelProperty
(
value
=
"个性签名"
)
private
String
signature
;
@ApiModelProperty
(
value
=
"手机号"
)
private
String
mobile
;
@ApiModelProperty
(
value
=
"邮箱"
)
private
String
email
;
@ApiModelProperty
(
value
=
"微信号"
)
private
String
wxNumber
;
@ApiModelProperty
(
value
=
"QQ号"
)
private
String
qqNumber
;
private
Date
createTime
;
private
Date
updateTime
;
/**
* 是否关注该用户
*/
private
Boolean
followedUser
;
private
UserStatistics
statistics
;
}
src/main/resources/application.yml
View file @
94cd9e42
...
...
@@ -4,7 +4,7 @@ spring:
driver-class-name
:
com.mysql.cj.jdbc.Driver
url
:
jdbc:mysql://127.0.0.1:3306/beyond_clouds?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true
username
:
root
password
:
2018006709
password
:
100Centa30821%mysql
# 邮箱
mail
:
...
...
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