2023-06-25 19:32:36 +00:00
|
|
|
package app
|
|
|
|
|
|
|
|
import (
|
|
|
|
"owl-blogs/app/repository"
|
|
|
|
"owl-blogs/domain/model"
|
2023-07-06 17:36:24 +00:00
|
|
|
"time"
|
2023-06-25 19:32:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type EntryService struct {
|
|
|
|
EntryRepository repository.EntryRepository
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewEntryService(entryRepository repository.EntryRepository) *EntryService {
|
|
|
|
return &EntryService{EntryRepository: entryRepository}
|
|
|
|
}
|
|
|
|
|
2023-07-06 17:36:24 +00:00
|
|
|
func (s *EntryService) Create(entry model.Entry, publishedAt *time.Time, metaData model.EntryMetaData) error {
|
|
|
|
return s.EntryRepository.Create(entry, publishedAt, metaData)
|
2023-06-25 19:32:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *EntryService) Update(entry model.Entry) error {
|
|
|
|
return s.EntryRepository.Update(entry)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *EntryService) Delete(entry model.Entry) error {
|
|
|
|
return s.EntryRepository.Delete(entry)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *EntryService) FindById(id string) (model.Entry, error) {
|
|
|
|
return s.EntryRepository.FindById(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *EntryService) FindAllByType(types *[]string) ([]model.Entry, error) {
|
|
|
|
return s.EntryRepository.FindAll(types)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *EntryService) FindAll() ([]model.Entry, error) {
|
|
|
|
return s.EntryRepository.FindAll(nil)
|
|
|
|
}
|