Files
RenewCMS/internal/infrastructure/useCases/GetMyAuthor.go
T

26 lines
510 B
Go

package useCases
import (
"RenewCMS/internal/domain/author"
"errors"
)
type GetMyAuthorUseCase struct {
authors author.Repository
}
func NewGetMyAuthorUseCase(authors author.Repository) *GetMyAuthorUseCase {
return &GetMyAuthorUseCase{authors: authors}
}
func (u *GetMyAuthorUseCase) Get(userID uint32) (*author.Author, error) {
found, err := u.authors.GetByUserID(userID)
if errors.Is(err, author.ErrAuthorNotFound) {
return nil, nil
}
if err != nil {
return nil, err
}
return &found, nil
}