mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
feat: images
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package useCases
|
||||
|
||||
import (
|
||||
"GoCMS/adapters/secondary/gateways"
|
||||
"GoCMS/domain/image"
|
||||
"gorm.io/gorm"
|
||||
"mime/multipart"
|
||||
)
|
||||
|
||||
type CreateImageUseCase struct {
|
||||
imageRepository gateways.ImageRepository
|
||||
}
|
||||
|
||||
func NewCreateImageUseCase(db *gorm.DB) *CreateImageUseCase {
|
||||
return &CreateImageUseCase{
|
||||
imageRepository: *gateways.NewImageRepository(db),
|
||||
}
|
||||
}
|
||||
|
||||
func (g *CreateImageUseCase) CreateImage(file multipart.File, fileHeader multipart.FileHeader) (image.Image, error) {
|
||||
return g.imageRepository.Create(file, fileHeader)
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package useCases
|
||||
|
||||
import (
|
||||
"GoCMS/adapters/secondary/gateways"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type DeleteImageUseCase struct {
|
||||
imageRepository gateways.ImageRepository
|
||||
}
|
||||
|
||||
func NewDeleteImageUseCase(db *gorm.DB) *DeleteImageUseCase {
|
||||
return &DeleteImageUseCase{
|
||||
imageRepository: *gateways.NewImageRepository(db),
|
||||
}
|
||||
}
|
||||
|
||||
func (g *DeleteImageUseCase) DeleteImage(imageId uint32) error {
|
||||
return g.imageRepository.Delete(imageId)
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package useCases
|
||||
|
||||
import (
|
||||
"GoCMS/adapters/secondary/gateways"
|
||||
"GoCMS/domain/post"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -15,6 +16,10 @@ func NewUpdatePostUseCase(db *gorm.DB) *UpdatePostUseCase {
|
||||
}
|
||||
}
|
||||
|
||||
func (g *UpdatePostUseCase) UpdateBody(id uint32, body string) error {
|
||||
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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user