Skip to content

Commit a790543

Browse files
dongzhengyu816Xuuuuuuuuuuuu董正宇
authored
feature: 关注模块redis重构 (X-Engineer#61)
* feature: 关注bugfix——主页关注数或粉丝数与详情页不一致和用户对粉丝全部关注的异常状况 * feature: 修改关注redis * fix: 重构关注模块集成redis的代码逻辑,初步完成优化 --------- Co-authored-by: mrxu <[email protected]> Co-authored-by: 董正宇 <[email protected]>
1 parent c95c55c commit a790543

File tree

5 files changed

+277
-211
lines changed

5 files changed

+277
-211
lines changed

Diff for: dao/followDao.go

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ func (*FollowDao) GetFriendsInfo(userId int64) ([]int64, int64, error) {
172172
}
173173
friendId = append(friendId[:i], friendId[i+1:]...)
174174
friendCnt--
175+
i--
175176
}
176177

177178
}

Diff for: dao/followDao_test.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
func TestFollowDao_InsertFollowRelation(t *testing.T) {
10-
followDao.InsertFollowRelation(2, 3)
10+
//followDao.InsertFollowRelation(2, 3)
1111
}
1212

1313
func TestFollowDao_FindRelation(t *testing.T) {
@@ -19,7 +19,8 @@ func TestFollowDao_FindRelation(t *testing.T) {
1919
}
2020

2121
func TestFollowDao_UpdateFollowRelation(t *testing.T) {
22-
followDao.UpdateFollowRelation(2, 3, 1)
22+
// followDao.UpdateFollowRelation(2, 3, 1)
23+
2324
}
2425

2526
func TestFollowDao_GetFollowingsInfo(t *testing.T) {
@@ -41,3 +42,11 @@ func TestFollowDao_GetUserName(t *testing.T) {
4142
}
4243
fmt.Println(name)
4344
}
45+
46+
func TestFollowDao_GetFriendsInfo(t *testing.T) {
47+
friendId, friendCnt, _ := followDao.GetFriendsInfo(6)
48+
49+
fmt.Println(friendId)
50+
fmt.Println(friendCnt)
51+
52+
}

Diff for: service/followService.go

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ type FriendUser struct {
99

1010
type FollowService interface {
1111

12+
/*
13+
模块业务所需的服务接口
14+
*/
1215
// FollowAction 当前用户关注目标用户
1316
FollowAction(userId int64, targetId int64) (bool, error)
1417
// CancelFollowAction 当前用户取消对目标用户的关注
@@ -20,6 +23,9 @@ type FollowService interface {
2023
// GetFriends 获取好友
2124
GetFriends(userId int64) ([]FriendUser, error)
2225

26+
/*
27+
模块对外提供的服务接口
28+
*/
2329
// GetFollowingCnt 根据用户id查询关注数
2430
GetFollowingCnt(userId int64) (int64, error)
2531
// GetFollowerCnt 根据用户id查询粉丝数

0 commit comments

Comments
 (0)