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/post"
"gorm.io/gorm"
)
type CreatePostUseCase struct {
postRepository gateways.PostRepository
postRepository gateways.IPostRepository
}
type CreatePostCommand struct {
@@ -15,10 +14,8 @@ type CreatePostCommand struct {
Body string
}
func NewCreatePostUseCase(db *gorm.DB) *CreatePostUseCase {
return &CreatePostUseCase{
postRepository: *gateways.NewPostRepository(db),
}
func NewCreatePostUseCase(postRepository gateways.IPostRepository) *CreatePostUseCase {
return &CreatePostUseCase{postRepository}
}
func (g *CreatePostUseCase) CreatePost(createPost CreatePostCommand) (post.Post, error) {