28 lines
680 B
Go
28 lines
680 B
Go
package useCases
|
|
|
|
import (
|
|
"RenewCMS/internal/domain/contenttype"
|
|
"RenewCMS/internal/domain/entry"
|
|
)
|
|
|
|
type GetEntryUseCase struct {
|
|
contentTypes contenttype.Repository
|
|
entries entry.Repository
|
|
}
|
|
|
|
func NewGetEntryUseCase(contentTypes contenttype.Repository, entries entry.Repository) *GetEntryUseCase {
|
|
return &GetEntryUseCase{contentTypes, entries}
|
|
}
|
|
|
|
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), nil
|
|
}
|