This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package service
|
||||
|
||||
import "butterfliu/internal/repository"
|
||||
import (
|
||||
"butterfliu/internal/repository"
|
||||
)
|
||||
|
||||
type SongService struct {
|
||||
songRepo *repository.SongRepository
|
||||
@@ -8,25 +10,21 @@ type SongService struct {
|
||||
}
|
||||
|
||||
func NewSongService(songRepo *repository.SongRepository, mediaRepo *repository.MediaRepository) *SongService {
|
||||
return &SongService{songRepo, mediaRepo}
|
||||
}
|
||||
|
||||
func (s *SongService) GetAll() ([]repository.Song, error) {
|
||||
return s.songRepo.GetAll()
|
||||
return &SongService{
|
||||
songRepo: songRepo,
|
||||
mediaRepo: mediaRepo,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SongService) GetAllWithDetails() ([]repository.SongDetail, error) {
|
||||
return s.songRepo.GetAllWithDetails()
|
||||
}
|
||||
|
||||
func (service *SongService) GetMediaFile(id int) (repository.MediaFile, error) {
|
||||
song, err := service.songRepo.Get(id)
|
||||
// GetMediaFilePath returns the file path of a song by its song ID.
|
||||
func (s *SongService) GetMediaFile(id int) (repository.MediaFile, error) {
|
||||
song, err := s.songRepo.Get(id)
|
||||
if err != nil {
|
||||
return repository.MediaFile{}, err
|
||||
}
|
||||
media, err := service.mediaRepo.Get(song.MediaFileID)
|
||||
if err != nil {
|
||||
return repository.MediaFile{}, err
|
||||
}
|
||||
return media, nil
|
||||
return s.mediaRepo.Get(song.MediaFileID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user