正在显示
3 个修改的文件
包含
12 行增加
和
3 行删除
@@ -54,8 +54,8 @@ func (l *MiniHomePageUserInfoLogic) MiniHomePageUserInfo(req *types.MiniHomePage | @@ -54,8 +54,8 @@ func (l *MiniHomePageUserInfoLogic) MiniHomePageUserInfo(req *types.MiniHomePage | ||
54 | Enable: user.Enable, | 54 | Enable: user.Enable, |
55 | }, | 55 | }, |
56 | TotalFollower: len(user.Follower), | 56 | TotalFollower: len(user.Follower), |
57 | - Followed: lo.Contains(currentUser.Following, user.Id), | ||
58 | - MutualFollowed: lo.Contains(user.Following, currentUser.Id), | 57 | + Followed: currentUser.IsFollowed(user.Id), |
58 | + MutualFollowed: currentUser.IsFriend(user.Id), | ||
59 | } | 59 | } |
60 | if company, _ := domain.LazyLoad(companyMap, l.ctx, conn, user.CompanyId, l.svcCtx.CompanyRepository.FindOne); company != nil { | 60 | if company, _ := domain.LazyLoad(companyMap, l.ctx, conn, user.CompanyId, l.svcCtx.CompanyRepository.FindOne); company != nil { |
61 | resp.User.CompanyName = company.Name | 61 | resp.User.CompanyName = company.Name |
@@ -76,7 +76,7 @@ func follower(ctx context.Context, svcCtx *svc.ServiceContext, user *domain.User | @@ -76,7 +76,7 @@ func follower(ctx context.Context, svcCtx *svc.ServiceContext, user *domain.User | ||
76 | Avatar: foundUser.Avatar, | 76 | Avatar: foundUser.Avatar, |
77 | Position: foundUser.Position, | 77 | Position: foundUser.Position, |
78 | Followed: true, | 78 | Followed: true, |
79 | - MutualFollowed: lo.Contains(user.Following, item), | 79 | + MutualFollowed: user.IsFriend(item), |
80 | }) | 80 | }) |
81 | } | 81 | } |
82 | }) | 82 | }) |
@@ -136,6 +136,15 @@ func (m *User) WithName(name string) *User { | @@ -136,6 +136,15 @@ func (m *User) WithName(name string) *User { | ||
136 | return m | 136 | return m |
137 | } | 137 | } |
138 | 138 | ||
139 | +func (m *User) IsFollowed(userId int64) bool { | ||
140 | + return lo.Contains(m.Following, userId) | ||
141 | +} | ||
142 | + | ||
143 | +// IsFriend 如果是好友,为互相关注 | ||
144 | +func (m *User) IsFriend(userId int64) bool { | ||
145 | + return lo.Contains(m.Following, userId) && lo.Contains(m.Follower, userId) | ||
146 | +} | ||
147 | + | ||
139 | type ( | 148 | type ( |
140 | LoginCreator interface { | 149 | LoginCreator interface { |
141 | WechatLogin(r WechatLoginRequest) (*LoginInfo, error) | 150 | WechatLogin(r WechatLoginRequest) (*LoginInfo, error) |
-
请 注册 或 登录 后发表评论