diff --git a/internal/rpc/friend/friend.go b/internal/rpc/friend/friend.go index e076aca55..5f91080db 100644 --- a/internal/rpc/friend/friend.go +++ b/internal/rpc/friend/friend.go @@ -223,7 +223,6 @@ func (s *friendServer) IsFriend(ctx context.Context, req *pbfriend.IsFriendReq) // ok func (s *friendServer) GetPaginationFriends(ctx context.Context, req *pbfriend.GetPaginationFriendsReq) (resp *pbfriend.GetPaginationFriendsResp, err error) { - resp = &pbfriend.GetPaginationFriendsResp{} if err := s.userCheck.Access(ctx, req.UserID); err != nil { return nil, err } @@ -231,6 +230,7 @@ func (s *friendServer) GetPaginationFriends(ctx context.Context, req *pbfriend.G if err != nil { return nil, err } + resp = &pbfriend.GetPaginationFriendsResp{} resp.FriendsInfo, err = (*convert.NewDBFriend(nil, s.RegisterCenter)).DB2PB(ctx, friends) if err != nil { return nil, err @@ -238,3 +238,15 @@ func (s *friendServer) GetPaginationFriends(ctx context.Context, req *pbfriend.G resp.Total = int32(total) return resp, nil } + +func (s *friendServer) GetFriendIDs(ctx context.Context, req *pbfriend.GetFriendIDsReq) (resp *pbfriend.GetFriendIDsResp, err error) { + if err := s.userCheck.Access(ctx, req.UserID); err != nil { + return nil, err + } + resp = &pbfriend.GetFriendIDsResp{} + resp.FriendIDs, err = s.FriendDatabase.GetFriendIDs(ctx, req.UserID) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/pkg/common/db/controller/friend.go b/pkg/common/db/controller/friend.go index c783dd3d8..80e8aae88 100644 --- a/pkg/common/db/controller/friend.go +++ b/pkg/common/db/controller/friend.go @@ -35,6 +35,7 @@ type FriendDatabase interface { PageFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) // 获取某人指定好友的信息 FindFriendsWithError(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error) + GetFriendIDs(ctx context.Context, ownerUserID string) (friendUserIDs []string, err error) } type friendDatabase struct { @@ -238,3 +239,7 @@ func (f *friendDatabase) FindFriendsWithError(ctx context.Context, ownerUserID s } return } + +func (f *friendDatabase) GetFriendIDs(ctx context.Context, ownerUserID string) (friendUserIDs []string, err error) { + return f.friend.FindFriendUserIDs(ctx, ownerUserID) +} diff --git a/pkg/common/db/table/relation/friend.go b/pkg/common/db/table/relation/friend.go index e9eb35c65..4ccbd55e9 100644 --- a/pkg/common/db/table/relation/friend.go +++ b/pkg/common/db/table/relation/friend.go @@ -48,6 +48,6 @@ type FriendModelInterface interface { FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*FriendModel, total int64, err error) // 获取好友UserID列表 FindFriendUserIDs(ctx context.Context, ownerUserID string) (friendUserIDs []string, err error) - + GetFriendIDs(ctx context.Context, ownerUserID string) (friendUserIDs []string, err error) NewTx(tx any) FriendModelInterface }