合并 origin/main 设备注册后,纳入本地 music 模块、seed 命令与 popadmin 相关路由/文档;music migration 编号为 0020 以避免与 0019_devices 冲突。 Co-authored-by: Cursor <cursoragent@cursor.com>
46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
package musichandler
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
|
|
musiclogic "spark-server/internal/module/music/logic"
|
|
"spark-server/internal/pkg/errs"
|
|
"spark-server/internal/transport/http/respond"
|
|
)
|
|
|
|
type Handler struct {
|
|
svc *musiclogic.Service
|
|
}
|
|
|
|
func New(svc *musiclogic.Service) *Handler {
|
|
return &Handler{svc: svc}
|
|
}
|
|
|
|
// Playlist GET /v1/music/playlist — public curated list + global preview seconds.
|
|
func (h *Handler) Playlist(c *gin.Context) {
|
|
if h == nil || h.svc == nil || !h.svc.Ready() {
|
|
respond.JSONError(c, errs.ErrAvailable)
|
|
return
|
|
}
|
|
out, err := h.svc.Playlist(c.Request.Context())
|
|
if err != nil {
|
|
respond.JSONError(c, err)
|
|
return
|
|
}
|
|
respond.JSON(c, out)
|
|
}
|
|
|
|
// Settings GET /v1/music/settings — global member preview seconds only.
|
|
func (h *Handler) Settings(c *gin.Context) {
|
|
if h == nil || h.svc == nil || !h.svc.Ready() {
|
|
respond.JSONError(c, errs.ErrAvailable)
|
|
return
|
|
}
|
|
out, err := h.svc.Settings(c.Request.Context())
|
|
if err != nil {
|
|
respond.JSONError(c, err)
|
|
return
|
|
}
|
|
respond.JSON(c, out)
|
|
}
|