refac: separated api content into sub-packages & renamed usecases

This commit is contained in:
Florian Sylvain
2025-03-13 19:43:12 +01:00
parent 7e29c08ea9
commit 4d6054e22b
38 changed files with 181 additions and 152 deletions
+29
View File
@@ -0,0 +1,29 @@
package useCases
import (
"GoCMS/adapters/secondary/gateways"
"GoCMS/domain/post"
"gorm.io/gorm"
)
type UpdatePostUseCase struct {
postRepository gateways.PostRepository
}
func NewUpdatePostUseCase(db *gorm.DB) *UpdatePostUseCase {
return &UpdatePostUseCase{
postRepository: *gateways.NewPostRepository(db),
}
}
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)
}