This commit is contained in:
@@ -67,20 +67,58 @@ func (s *LibraryService) GetSongs(id int) ([]repository.SongDetail, error) {
|
||||
return s.repo.GetSongsByLibraryWithDetails(id)
|
||||
}
|
||||
|
||||
func (s *LibraryService) GetSongsByArtist(id int) ([]repository.SongDetail, error) {
|
||||
return s.repo.GetSongsByArtistWithDetails(id)
|
||||
}
|
||||
|
||||
func (s *LibraryService) GetSongsByAlbum(id int) ([]repository.SongDetail, error) {
|
||||
return s.repo.GetSongsByAlbumWithDetails(id)
|
||||
}
|
||||
|
||||
func (s *LibraryService) GetArtists() ([]model.Artist, error) {
|
||||
return s.repo.GetArtists()
|
||||
}
|
||||
|
||||
func (s *LibraryService) GetArtist(id int) (model.Artist, error) {
|
||||
return s.repo.GetArtist(id)
|
||||
func (s *LibraryService) GetArtist(id int) (model.ArtistDetail, error) {
|
||||
artist, err := s.repo.GetArtist(id)
|
||||
if err != nil {
|
||||
return model.ArtistDetail{}, err
|
||||
}
|
||||
albums, err := s.repo.GetAlbumIDsByArtist(id)
|
||||
if err != nil {
|
||||
return model.ArtistDetail{}, err
|
||||
}
|
||||
songs, err := s.repo.GetSongIDsByArtist(id)
|
||||
if err != nil {
|
||||
return model.ArtistDetail{}, err
|
||||
}
|
||||
return model.ArtistDetail{
|
||||
ID: artist.ID,
|
||||
Name: artist.Name,
|
||||
Songs: songs,
|
||||
Albums: albums,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *LibraryService) GetAlbums() ([]model.Album, error) {
|
||||
return s.repo.GetAlbums()
|
||||
}
|
||||
|
||||
func (s *LibraryService) GetAlbum(id int) (model.Album, error) {
|
||||
return s.repo.GetAlbum(id)
|
||||
func (s *LibraryService) GetAlbum(id int) (model.AlbumDetail, error) {
|
||||
album, err := s.repo.GetAlbum(id)
|
||||
if err != nil {
|
||||
return model.AlbumDetail{}, err
|
||||
}
|
||||
songs, err := s.repo.GetSongIDsByAlbum(id)
|
||||
if err != nil {
|
||||
return model.AlbumDetail{}, err
|
||||
}
|
||||
return model.AlbumDetail{
|
||||
ID: id,
|
||||
Title: album.Title,
|
||||
Songs: songs,
|
||||
Artist: album.ArtistID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *LibraryService) Scan(id int) (*ScanReport, error) {
|
||||
|
||||
Reference in New Issue
Block a user