package handler import ( "net/http" "github.com/gin-gonic/gin" "github.com/yuxingu/digital-psychology/apps/api/internal/repository" "github.com/yuxingu/digital-psychology/apps/api/pkg/response" ) // RhythmConfigPublicHandler serves GET /api/v1/rhythm/configs (DeviceAuth). type RhythmConfigPublicHandler struct { Repo *repository.AdminRepo } // Register mounts public rhythm config routes. func (h *RhythmConfigPublicHandler) Register(api *gin.RouterGroup) { api.GET("/rhythm/configs", h.ListActive) } func (h *RhythmConfigPublicHandler) ListActive(c *gin.Context) { if h.Repo == nil { response.OK(c, gin.H{"items": []repository.RhythmConfigRow{}}) return } items, err := h.Repo.ListActiveRhythmConfigs(c.Request.Context()) if err != nil { response.Fail(c, http.StatusInternalServerError, 50054, "rhythm configs failed") return } if items == nil { items = []repository.RhythmConfigRow{} } response.OK(c, gin.H{"items": items}) }