mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 19:53:21 +02:00
Renamed the 'Article' domain to 'Post' in order to better reflect the purpose and utility of the object. The change involved renaming all related use cases, classes, and other references from 'Article' to 'Post' and updating all functions and data types to work with Posts instead of Articles.
30 lines
572 B
Go
30 lines
572 B
Go
package useCases
|
|
|
|
import (
|
|
"GohCMS2/adapters/secondary/gateways"
|
|
"GohCMS2/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,
|
|
))
|
|
}
|