添加详情接口
All checks were successful
Go CI / test-and-build (push) Successful in 11s

This commit is contained in:
2026-04-07 16:08:02 +08:00
parent c5102e608d
commit 02efb9972a
5 changed files with 53 additions and 2 deletions

View File

@@ -63,6 +63,21 @@ func (r *SongRepository) GetAllWithDetails() ([]SongDetail, error) {
return songs, nil
}
func (r *SongRepository) GetWithDetails(id int) (model.SongDetail, error) {
var song model.SongDetail
err := r.db.QueryRow(`
SELECT s.id, s.title, a.name as artist_name, al.title as album_title, s.duration, mf.path
FROM songs s WHERE 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 albums al ON s.album_id = al.id
`, id).Scan(&song.ID, &song.Title, &song.Artist, &song.Album, &song.Duration, &song.Path)
if err != nil {
return model.SongDetail{}, err
}
return song, nil
}
func (r *SongRepository) Get(id int) (model.Song, error) {
var song model.Song
err := r.db.QueryRow(`