mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 19:53:21 +02:00
33 lines
639 B
Go
33 lines
639 B
Go
package useCases
|
|
|
|
import (
|
|
"RenewCMS/domain/gateways"
|
|
"RenewCMS/domain/user"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type CreateUserUseCase struct {
|
|
userRepository gateways.IUserRepository
|
|
}
|
|
|
|
type CreateUserCommand struct {
|
|
Username string
|
|
Password string
|
|
Email string
|
|
}
|
|
|
|
func NewCreateUserUseCase(userRepository gateways.IUserRepository) *CreateUserUseCase {
|
|
return &CreateUserUseCase{userRepository}
|
|
}
|
|
|
|
func (g *CreateUserUseCase) CreateUser(createUser CreateUserCommand) (user.User, error) {
|
|
return g.userRepository.Create(user.FromApi(
|
|
createUser.Username,
|
|
createUser.Password,
|
|
"",
|
|
createUser.Email,
|
|
uuid.NewString(),
|
|
))
|
|
}
|