refac: fixed, better, smarter, correct dependency injection

This commit is contained in:
Florian Sylvain
2025-03-29 00:51:01 +01:00
parent d895477b8c
commit a77a5ad314
35 changed files with 169 additions and 144 deletions
+4 -7
View File
@@ -1,13 +1,12 @@
package useCases
import (
"GoCMS/adapters/secondary/gateways"
"GoCMS/domain/gateways"
"GoCMS/domain/user"
"gorm.io/gorm"
)
type CreateUserUseCase struct {
userRepository gateways.UserRepository
userRepository gateways.IUserRepository
}
type CreateUserCommand struct {
@@ -17,10 +16,8 @@ type CreateUserCommand struct {
VerificationCode string
}
func NewCreateUserUseCase(db *gorm.DB) *CreateUserUseCase {
return &CreateUserUseCase{
userRepository: *gateways.NewUserRepository(db),
}
func NewCreateUserUseCase(userRepository gateways.IUserRepository) *CreateUserUseCase {
return &CreateUserUseCase{userRepository}
}
func (g *CreateUserUseCase) CreateUser(createUser CreateUserCommand) (user.User, error) {