This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user