添加歌曲封面接口
All checks were successful
Go CI / test-and-build (push) Successful in 12s

This commit is contained in:
2026-04-06 23:16:34 +08:00
parent 3182b29932
commit 0b7cd05486
5 changed files with 63 additions and 1 deletions

View File

@@ -41,3 +41,18 @@ func (c *SongController) Stream(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, mediaFile.Path)
}
func (c *SongController) Cover(w http.ResponseWriter, r *http.Request) {
paramID := chi.URLParam(r, "id")
id, err := strconv.Atoi(paramID)
if err != nil {
http.Error(w, "无效的歌曲 ID", http.StatusBadRequest)
return
}
coverPath, err := c.service.GetCover(id)
if err != nil {
http.Error(w, "获取封面异常", http.StatusNotFound)
return
}
http.ServeFile(w, r, coverPath)
}