mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
clean: Article to Post in domain and related use cases
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.
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
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,
|
||||
))
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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,
|
||||
))
|
||||
}
|
||||
@@ -2,20 +2,20 @@ package useCases
|
||||
|
||||
import (
|
||||
"GohCMS2/adapters/secondary/gateways"
|
||||
"GohCMS2/domain/article"
|
||||
"GohCMS2/domain/post"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type GetArticleUseCase struct {
|
||||
articleRepository gateways.ArticleRepository
|
||||
articleRepository gateways.PostRepository
|
||||
}
|
||||
|
||||
func NewGetArticleUseCase(db *gorm.DB) *GetArticleUseCase {
|
||||
return &GetArticleUseCase{
|
||||
articleRepository: *gateways.NewArticleRepository(db),
|
||||
articleRepository: *gateways.NewPostRepository(db),
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GetArticleUseCase) GetArticle(id uint32) (article.Article, error) {
|
||||
func (g *GetArticleUseCase) GetArticle(id uint32) (post.Post, error) {
|
||||
return g.articleRepository.Get(id)
|
||||
}
|
||||
@@ -2,20 +2,20 @@ package useCases
|
||||
|
||||
import (
|
||||
"GohCMS2/adapters/secondary/gateways"
|
||||
"GohCMS2/domain/article"
|
||||
"GohCMS2/domain/post"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ListArticlesUseCase struct {
|
||||
articleRepository gateways.ArticleRepository
|
||||
articleRepository gateways.PostRepository
|
||||
}
|
||||
|
||||
func NewListArticlesUseCase(db *gorm.DB) *ListArticlesUseCase {
|
||||
return &ListArticlesUseCase{
|
||||
articleRepository: *gateways.NewArticleRepository(db),
|
||||
articleRepository: *gateways.NewPostRepository(db),
|
||||
}
|
||||
}
|
||||
|
||||
func (g *ListArticlesUseCase) ListArticles() []article.Article {
|
||||
func (g *ListArticlesUseCase) ListArticles() []post.Post {
|
||||
return g.articleRepository.GetAll()
|
||||
}
|
||||
Reference in New Issue
Block a user