Files
digital-psychology/apps/api/internal/handler/rhythm_config_public.go
T
jackyu66gitandCursor 87b463b2bb feat(ECR-044): RhythmConfig 写面闭环并 Closed
复用 admin.explore.write、POST/PUT+审计、C端 GET /rhythm/configs、
H5 无 active 空态/失败回退;migration 000053。ExploreConfig Loop STOP,禁自动 ECR-045。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-13 20:43:08 +08:00

37 lines
959 B
Go

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})
}