owl-blogs/app/binary_service.go

38 lines
1.0 KiB
Go
Raw Permalink Normal View History

2023-07-08 09:08:55 +00:00
package app
import (
"owl-blogs/app/repository"
"owl-blogs/domain/model"
)
type BinaryService struct {
repo repository.BinaryRepository
}
func NewBinaryFileService(repo repository.BinaryRepository) *BinaryService {
return &BinaryService{repo: repo}
}
func (s *BinaryService) Create(name string, file []byte) (*model.BinaryFile, error) {
2023-07-09 19:27:59 +00:00
return s.repo.Create(name, file, nil)
2023-07-08 09:08:55 +00:00
}
2023-07-13 18:39:24 +00:00
func (s *BinaryService) CreateEntryFile(name string, file []byte, entry model.Entry) (*model.BinaryFile, error) {
return s.repo.Create(name, file, entry)
}
2023-07-08 09:08:55 +00:00
func (s *BinaryService) FindById(id string) (*model.BinaryFile, error) {
return s.repo.FindById(id)
}
2023-07-27 20:02:13 +00:00
2024-02-23 11:34:05 +00:00
// ListIds list all ids of binary files
// if filter is not empty, the list will be filter to all ids which include the filter filter substring
// ids and filters are compared in lower case
func (s *BinaryService) ListIds(filter string) ([]string, error) {
return s.repo.ListIds(filter)
2023-07-27 20:02:13 +00:00
}
func (s *BinaryService) Delete(binary *model.BinaryFile) error {
return s.repo.Delete(binary)
}