mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
refac: renamed 'post' -> 'article'
This commit is contained in:
@@ -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,
|
||||
))
|
||||
}
|
||||
@@ -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,
|
||||
))
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user