mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
28 lines
564 B
Go
28 lines
564 B
Go
package useCases
|
|
|
|
import (
|
|
. "GohCMS2/adapters/secondary/gateways"
|
|
. "GohCMS2/domain/user"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type CreateUserUseCase struct {
|
|
userRepository UserRepository
|
|
}
|
|
|
|
type CreateUserCommand struct {
|
|
Username string
|
|
Password string
|
|
Email string
|
|
}
|
|
|
|
func NewCreateUserUseCase(db *gorm.DB) *CreateUserUseCase {
|
|
return &CreateUserUseCase{
|
|
userRepository: *NewUserRepository(db),
|
|
}
|
|
}
|
|
|
|
func (g *CreateUserUseCase) CreateUser(user CreateUserCommand) (User, error) {
|
|
return g.userRepository.Create(FromApi(user.Username, user.Password, user.Email))
|
|
}
|