清理代码库
All checks were successful
Go CI / test-and-build (push) Successful in 43s

This commit is contained in:
2026-04-06 13:17:57 +08:00
parent eda0ac9e40
commit a8d976b97e
9 changed files with 94 additions and 571 deletions

View File

@@ -2,7 +2,6 @@ package controller
import (
"butterfliu/internal/service"
"encoding/json"
"net/http"
"strconv"
@@ -20,15 +19,15 @@ func NewSongController(service *service.SongService) *SongController {
func (c *SongController) GetAllWithDetails(w http.ResponseWriter, r *http.Request) {
songs, err := c.service.GetAllWithDetails()
if err != nil {
json.NewEncoder(w).Encode(map[string]string{"error": err.Error()})
jsonError(w, err.Error(), http.StatusInternalServerError)
return
}
json.NewEncoder(w).Encode(songs)
jsonResponse(w, songs, http.StatusOK)
}
func (c *SongController) Stream(w http.ResponseWriter, r *http.Request) {
parmaID := chi.URLParam(r, "id")
id, err := strconv.Atoi(parmaID)
paramID := chi.URLParam(r, "id")
id, err := strconv.Atoi(paramID)
if err != nil {
http.Error(w, "无效的歌曲 ID", http.StatusBadRequest)
return