作者 yangfu

Merge branch 'dev' into test

... ... @@ -54,8 +54,8 @@ func (l *MiniHomePageUserInfoLogic) MiniHomePageUserInfo(req *types.MiniHomePage
Enable: user.Enable,
},
TotalFollower: len(user.Follower),
Followed: lo.Contains(currentUser.Following, user.Id),
MutualFollowed: lo.Contains(user.Following, currentUser.Id),
Followed: currentUser.IsFollowed(user.Id),
MutualFollowed: currentUser.IsFriend(user.Id),
}
if company, _ := domain.LazyLoad(companyMap, l.ctx, conn, user.CompanyId, l.svcCtx.CompanyRepository.FindOne); company != nil {
resp.User.CompanyName = company.Name
... ...
... ... @@ -76,7 +76,7 @@ func follower(ctx context.Context, svcCtx *svc.ServiceContext, user *domain.User
Avatar: foundUser.Avatar,
Position: foundUser.Position,
Followed: true,
MutualFollowed: lo.Contains(user.Following, item),
MutualFollowed: user.IsFriend(item),
})
}
})
... ...
... ... @@ -136,6 +136,15 @@ func (m *User) WithName(name string) *User {
return m
}
func (m *User) IsFollowed(userId int64) bool {
return lo.Contains(m.Following, userId)
}
// IsFriend 如果是好友,为互相关注
func (m *User) IsFriend(userId int64) bool {
return lo.Contains(m.Following, userId) && lo.Contains(m.Follower, userId)
}
type (
LoginCreator interface {
WechatLogin(r WechatLoginRequest) (*LoginInfo, error)
... ...