mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
refac: fixed, better, smarter, correct dependency injection
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user