对接
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package live
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
bizlive "kra/internal/biz/live"
|
||||
)
|
||||
|
||||
type FollowService struct{ uc *bizlive.FollowUsecase }
|
||||
|
||||
func NewFollowService(uc *bizlive.FollowUsecase) *FollowService { return &FollowService{uc: uc} }
|
||||
|
||||
func (s *FollowService) Status(ctx context.Context, userID, roomID uint) (bool, error) {
|
||||
_, err := s.uc.Get(ctx, userID, roomID)
|
||||
if err == nil {
|
||||
return true, nil
|
||||
}
|
||||
if errors.Is(err, bizlive.ErrFollowNotFound) {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
|
||||
func (s *FollowService) Follow(ctx context.Context, userID, roomID uint) (bool, error) {
|
||||
_, err := s.uc.Follow(ctx, userID, roomID)
|
||||
return err == nil, err
|
||||
}
|
||||
|
||||
func (s *FollowService) Unfollow(ctx context.Context, userID, roomID uint) error {
|
||||
return s.uc.Unfollow(ctx, userID, roomID)
|
||||
}
|
||||
Reference in New Issue
Block a user