sessions/internal/service/user.go
Dawid Wysokiński 5b061dfef3
All checks were successful
continuous-integration/drone/push Build is passing
feat: add a new command - db user create (#4)
Reviewed-on: #4
2022-11-19 07:24:05 +00:00

30 lines
584 B
Go

package service
import (
"context"
"fmt"
"gitea.dwysokinski.me/twhelp/sessions/internal/domain"
)
type UserRepository interface {
Create(ctx context.Context, params domain.CreateUserParams) (domain.User, error)
}
type User struct {
repo UserRepository
}
func NewUser(repo UserRepository) *User {
return &User{repo: repo}
}
func (u *User) Create(ctx context.Context, params domain.CreateUserParams) (domain.User, error) {
user, err := u.repo.Create(ctx, params)
if err != nil {
return domain.User{}, fmt.Errorf("UserRepository.Create: %w", err)
}
return user, nil
}