31 lines
751 B
Go
31 lines
751 B
Go
package service
|
|
|
|
import (
|
|
"butterfliu/internal/repository"
|
|
)
|
|
|
|
type SongService struct {
|
|
songRepo *repository.SongRepository
|
|
mediaRepo *repository.MediaRepository
|
|
}
|
|
|
|
func NewSongService(songRepo *repository.SongRepository, mediaRepo *repository.MediaRepository) *SongService {
|
|
return &SongService{
|
|
songRepo: songRepo,
|
|
mediaRepo: mediaRepo,
|
|
}
|
|
}
|
|
|
|
func (s *SongService) GetAllWithDetails() ([]repository.SongDetail, error) {
|
|
return s.songRepo.GetAllWithDetails()
|
|
}
|
|
|
|
// 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
|
|
}
|
|
return s.mediaRepo.Get(song.MediaFileID)
|
|
}
|