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