30 lines
801 B
Go
30 lines
801 B
Go
package useCases
|
|
|
|
import (
|
|
"RenewCMS/internal/domain/contenttype"
|
|
"RenewCMS/internal/domain/entry"
|
|
"RenewCMS/internal/domain/image"
|
|
)
|
|
|
|
type GetEntryUseCase struct {
|
|
contentTypes contenttype.Repository
|
|
entries entry.Repository
|
|
images image.Repository
|
|
}
|
|
|
|
func NewGetEntryUseCase(contentTypes contenttype.Repository, entries entry.Repository, images image.Repository) *GetEntryUseCase {
|
|
return &GetEntryUseCase{contentTypes, entries, images}
|
|
}
|
|
|
|
func (u *GetEntryUseCase) Get(contentTypeKey string, id uint32) (TypedEntry, error) {
|
|
owner, err := u.contentTypes.GetByKey(contentTypeKey)
|
|
if err != nil {
|
|
return TypedEntry{}, err
|
|
}
|
|
found, err := u.entries.Get(owner.ID, id)
|
|
if err != nil {
|
|
return TypedEntry{}, err
|
|
}
|
|
return typedEntry(owner, found, newMediaResolver(u.images))
|
|
}
|