mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
27 lines
576 B
Go
27 lines
576 B
Go
package useCases
|
|
|
|
import (
|
|
. "GohCMS2/adapters/secondary/gateways"
|
|
. "GohCMS2/domain/article"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type CreateArticleUseCase struct {
|
|
articleRepository ArticleRepository
|
|
}
|
|
|
|
type CreateArticleCommand struct {
|
|
Title string
|
|
Body string
|
|
}
|
|
|
|
func NewCreateArticleUseCase(db *gorm.DB) *CreateArticleUseCase {
|
|
return &CreateArticleUseCase{
|
|
articleRepository: *NewArticleRepository(db),
|
|
}
|
|
}
|
|
|
|
func (g *CreateArticleUseCase) CreateArticle(article CreateArticleCommand) (Article, error) {
|
|
return g.articleRepository.Create(FromApi(article.Title, article.Body))
|
|
}
|