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,19 +1,16 @@
package useCases
import (
"GoCMS/adapters/secondary/gateways"
"GoCMS/domain/gateways"
"GoCMS/domain/post"
"gorm.io/gorm"
)
type ListPostsUseCase struct {
postRepository gateways.PostRepository
postRepository gateways.IPostRepository
}
func NewListPostsUseCase(db *gorm.DB) *ListPostsUseCase {
return &ListPostsUseCase{
postRepository: *gateways.NewPostRepository(db),
}
func NewListPostsUseCase(postRepository gateways.IPostRepository) *ListPostsUseCase {
return &ListPostsUseCase{postRepository}
}
func (g *ListPostsUseCase) ListPosts() []post.Post {