refac: renamed 'post' -> 'article'

This commit is contained in:
Florian Sylvain
2025-11-17 19:27:48 +01:00
parent cb9a431488
commit b470bfcc67
44 changed files with 701 additions and 967 deletions
+26
View File
@@ -0,0 +1,26 @@
package useCases
import (
"GoCMS/domain/article"
"GoCMS/domain/gateways"
)
type CreateArticleUseCase struct {
articleRepository gateways.IArticleRepository
}
type CreateArticleCommand struct {
Title string
Body string
}
func NewCreateArticleUseCase(articleRepository gateways.IArticleRepository) *CreateArticleUseCase {
return &CreateArticleUseCase{articleRepository}
}
func (g *CreateArticleUseCase) CreateArticle(createArticle CreateArticleCommand) (article.Article, error) {
return g.articleRepository.Create(article.FromApi(
createArticle.Title,
createArticle.Body,
))
}
-26
View File
@@ -1,26 +0,0 @@
package useCases
import (
"GoCMS/domain/gateways"
"GoCMS/domain/post"
)
type CreatePostUseCase struct {
postRepository gateways.IPostRepository
}
type CreatePostCommand struct {
Title string
Body string
}
func NewCreatePostUseCase(postRepository gateways.IPostRepository) *CreatePostUseCase {
return &CreatePostUseCase{postRepository}
}
func (g *CreatePostUseCase) CreatePost(createPost CreatePostCommand) (post.Post, error) {
return g.postRepository.Create(post.FromApi(
createPost.Title,
createPost.Body,
))
}
+17
View File
@@ -0,0 +1,17 @@
package useCases
import (
"GoCMS/domain/gateways"
)
type DeleteArticleUseCase struct {
articleRepository gateways.IArticleRepository
}
func NewDeleteArticleUseCase(articleRepository gateways.IArticleRepository) *DeleteArticleUseCase {
return &DeleteArticleUseCase{articleRepository}
}
func (g *DeleteArticleUseCase) DeleteArticle(userId uint32) error {
return g.articleRepository.Delete(userId)
}
-17
View File
@@ -1,17 +0,0 @@
package useCases
import (
"GoCMS/domain/gateways"
)
type DeletePostUseCase struct {
postRepository gateways.IPostRepository
}
func NewDeletePostUseCase(postRepository gateways.IPostRepository) *DeletePostUseCase {
return &DeletePostUseCase{postRepository}
}
func (g *DeletePostUseCase) DeletePost(userId uint32) error {
return g.postRepository.Delete(userId)
}
+22
View File
@@ -0,0 +1,22 @@
package useCases
import (
"GoCMS/domain/article"
"GoCMS/domain/gateways"
)
type GetArticleUseCase struct {
articleRepository gateways.IArticleRepository
}
func NewGetArticleUseCase(articleRepository gateways.IArticleRepository) *GetArticleUseCase {
return &GetArticleUseCase{articleRepository}
}
func (g *GetArticleUseCase) GetArticle(id uint32) (article.Article, error) {
return g.articleRepository.Get(id)
}
func (g *GetArticleUseCase) GetArticleByName(name string) (article.Article, error) {
return g.articleRepository.GetByName(name)
}
-22
View File
@@ -1,22 +0,0 @@
package useCases
import (
"GoCMS/domain/gateways"
"GoCMS/domain/post"
)
type GetPostUseCase struct {
postRepository gateways.IPostRepository
}
func NewGetPostUseCase(postRepository gateways.IPostRepository) *GetPostUseCase {
return &GetPostUseCase{postRepository}
}
func (g *GetPostUseCase) GetPost(id uint32) (post.Post, error) {
return g.postRepository.Get(id)
}
func (g *GetPostUseCase) GetPostByName(name string) (post.Post, error) {
return g.postRepository.GetByName(name)
}
+18
View File
@@ -0,0 +1,18 @@
package useCases
import (
"GoCMS/domain/article"
"GoCMS/domain/gateways"
)
type ListArticlesUseCase struct {
articleRepository gateways.IArticleRepository
}
func NewListArticlesUseCase(articleRepository gateways.IArticleRepository) *ListArticlesUseCase {
return &ListArticlesUseCase{articleRepository}
}
func (g *ListArticlesUseCase) ListArticles() []article.Article {
return g.articleRepository.GetAll()
}
-18
View File
@@ -1,18 +0,0 @@
package useCases
import (
"GoCMS/domain/gateways"
"GoCMS/domain/post"
)
type ListPostsUseCase struct {
postRepository gateways.IPostRepository
}
func NewListPostsUseCase(postRepository gateways.IPostRepository) *ListPostsUseCase {
return &ListPostsUseCase{postRepository}
}
func (g *ListPostsUseCase) ListPosts() []post.Post {
return g.postRepository.GetAll()
}
+26
View File
@@ -0,0 +1,26 @@
package useCases
import (
"GoCMS/domain/article"
"GoCMS/domain/gateways"
)
type UpdateArticleUseCase struct {
articleRepository gateways.IArticleRepository
}
func NewUpdateArticleUseCase(articleRepository gateways.IArticleRepository) *UpdateArticleUseCase {
return &UpdateArticleUseCase{articleRepository}
}
func (g *UpdateArticleUseCase) UpdateBody(id uint32, body string) (article.Article, error) {
return g.articleRepository.UpdateBody(id, body)
}
func (g *UpdateArticleUseCase) AddImage(articleId uint32, imageId uint32) error {
return g.articleRepository.AddImage(articleId, imageId)
}
func (g *UpdateArticleUseCase) UpdateIsOnline(id uint32, isOnline bool) (article.Article, error) {
return g.articleRepository.UpdateIsOnline(id, isOnline)
}
-26
View File
@@ -1,26 +0,0 @@
package useCases
import (
"GoCMS/domain/gateways"
"GoCMS/domain/post"
)
type UpdatePostUseCase struct {
postRepository gateways.IPostRepository
}
func NewUpdatePostUseCase(postRepository gateways.IPostRepository) *UpdatePostUseCase {
return &UpdatePostUseCase{postRepository}
}
func (g *UpdatePostUseCase) UpdateBody(id uint32, body string) (post.Post, error) {
return g.postRepository.UpdateBody(id, body)
}
func (g *UpdatePostUseCase) AddImage(postId uint32, imageId uint32) error {
return g.postRepository.AddImage(postId, imageId)
}
func (g *UpdatePostUseCase) UpdateIsOnline(id uint32, isOnline bool) (post.Post, error) {
return g.postRepository.UpdateIsOnline(id, isOnline)
}