refac: separated api content into sub-packages & renamed usecases

This commit is contained in:
Florian Sylvain
2025-03-13 19:43:12 +01:00
parent 7e29c08ea9
commit 4d6054e22b
38 changed files with 181 additions and 152 deletions
+29
View File
@@ -0,0 +1,29 @@
package useCases
import (
"GoCMS/adapters/secondary/gateways"
"GoCMS/domain/post"
"gorm.io/gorm"
)
type CreatePostUseCase struct {
postRepository gateways.PostRepository
}
type CreatePostCommand struct {
Title string
Body string
}
func NewCreatePostUseCase(db *gorm.DB) *CreatePostUseCase {
return &CreatePostUseCase{
postRepository: *gateways.NewPostRepository(db),
}
}
func (g *CreatePostUseCase) CreatePost(createPost CreatePostCommand) (post.Post, error) {
return g.postRepository.Create(post.FromApi(
createPost.Title,
createPost.Body,
))
}