复用 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>
37 lines
959 B
Go
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})
|
|
}
|