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
@@ -1,4 +1,4 @@
package post
package article
import (
entity "GoCMS/adapters/secondary/gateways/models"
@@ -6,7 +6,7 @@ import (
"time"
)
type Post struct {
type Article struct {
ID uint32 `json:"id"`
Title string `json:"title"`
Body string `json:"body"`
@@ -19,8 +19,8 @@ type Post struct {
func FromApi(
title string,
body string,
) Post {
return Post{
) Article {
return Article{
Title: title,
Body: body,
}
@@ -34,19 +34,19 @@ func FromDb(
isOnline bool,
createdAt time.Time,
updatedAt time.Time,
) Post {
) Article {
domainImages := make([]*domain.Image, len(images))
for i, img := range images {
domainImage := domain.FromDB(
img.ID,
img.Path,
img.PostID,
img.ArticleID,
img.CreatedAt,
img.UpdatedAt,
)
domainImages[i] = &domainImage
}
return Post{
return Article{
ID: id,
Title: title,
Body: body,
+16
View File
@@ -0,0 +1,16 @@
package gateways
import (
"GoCMS/domain/article"
)
type IArticleRepository interface {
Get(id uint32) (article.Article, error)
GetByName(name string) (article.Article, error)
GetAll() []article.Article
Create(post article.Article) (article.Article, error)
UpdateBody(id uint32, body string) (article.Article, error)
UpdateIsOnline(id uint32, isOnline bool) (article.Article, error)
Delete(id uint32) error
AddImage(postId uint32, imageId uint32) error
}
-16
View File
@@ -1,16 +0,0 @@
package gateways
import (
"GoCMS/domain/post"
)
type IPostRepository interface {
Get(id uint32) (post.Post, error)
GetByName(name string) (post.Post, error)
GetAll() []post.Post
Create(post post.Post) (post.Post, error)
UpdateBody(id uint32, body string) (post.Post, error)
UpdateIsOnline(id uint32, isOnline bool) (post.Post, error)
Delete(id uint32) error
AddImage(postId uint32, imageId uint32) error
}
+3 -3
View File
@@ -7,16 +7,16 @@ import (
type Image struct {
ID uint32 `json:"id"`
Path string `json:"path"`
PostID uint32 `json:"post_id"`
ArticleID uint32 `json:"article_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func FromDB(id uint32, path string, postId uint32, createdAt time.Time, updatedAt time.Time) Image {
func FromDB(id uint32, path string, articleId uint32, createdAt time.Time, updatedAt time.Time) Image {
return Image{
ID: id,
Path: path,
PostID: postId,
ArticleID: articleId,
CreatedAt: createdAt,
UpdatedAt: updatedAt,
}