This commit is contained in:
@@ -67,10 +67,11 @@ func (r *SongRepository) GetWithDetails(id int) (model.SongDetail, error) {
|
|||||||
var song model.SongDetail
|
var song model.SongDetail
|
||||||
err := r.db.QueryRow(`
|
err := r.db.QueryRow(`
|
||||||
SELECT s.id, s.title, a.name as artist_name, al.title as album_title, s.duration, mf.path
|
SELECT s.id, s.title, a.name as artist_name, al.title as album_title, s.duration, mf.path
|
||||||
FROM songs s WHERE id = ?
|
FROM songs s
|
||||||
INNER JOIN media_files mf ON s.media_file_id = mf.id
|
INNER JOIN media_files mf ON s.media_file_id = mf.id
|
||||||
INNER JOIN artists a ON s.artist_id = a.id
|
INNER JOIN artists a ON s.artist_id = a.id
|
||||||
INNER JOIN albums al ON s.album_id = al.id
|
INNER JOIN albums al ON s.album_id = al.id
|
||||||
|
WHERE s.id = ?
|
||||||
`, id).Scan(&song.ID, &song.Title, &song.Artist, &song.Album, &song.Duration, &song.Path)
|
`, id).Scan(&song.ID, &song.Title, &song.Artist, &song.Album, &song.Duration, &song.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return model.SongDetail{}, err
|
return model.SongDetail{}, err
|
||||||
|
|||||||
1
main.go
1
main.go
@@ -56,7 +56,6 @@ func main() {
|
|||||||
r.Route("/api/artists", func(r chi.Router) {
|
r.Route("/api/artists", func(r chi.Router) {
|
||||||
r.Get("/", libraryController.GetArtists)
|
r.Get("/", libraryController.GetArtists)
|
||||||
r.Get("/{id}", libraryController.GetArtist)
|
r.Get("/{id}", libraryController.GetArtist)
|
||||||
r.Get("/{id}", libraryController.GetArtist)
|
|
||||||
r.Get("/{id}/songs", libraryController.GetSongsByArtist)
|
r.Get("/{id}/songs", libraryController.GetSongsByArtist)
|
||||||
r.Get("/{id}/albums", libraryController.GetAlbumsByArtist)
|
r.Get("/{id}/albums", libraryController.GetAlbumsByArtist)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user