feat(ECR-036): ExploreConfig RhythmConfig 只读并 Closed

RhythmConfig catalog (000037) · Loop continuous.
This commit is contained in:
jackyu66git
2026-08-08 03:16:26 +08:00
parent 57acfa6105
commit bd9e13497f
25 changed files with 455 additions and 1 deletions
+1
View File
@@ -64,6 +64,7 @@ func (h *AdminHandler) Register(api *gin.RouterGroup) {
h.registerHandoffCases(authed)
h.registerPrivacyRequests(authed)
h.registerStarConfigs(authed)
h.registerRhythmConfigs(authed)
}
func (h *AdminHandler) Login(c *gin.Context) {
@@ -0,0 +1,46 @@
package handler
import (
"errors"
"net/http"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"github.com/yuxingu/digital-psychology/apps/api/internal/middleware"
"github.com/yuxingu/digital-psychology/apps/api/internal/service/admin"
"github.com/yuxingu/digital-psychology/apps/api/pkg/response"
)
func (h *AdminHandler) registerRhythmConfigs(authed *gin.RouterGroup) {
g := authed.Group("/explore")
g.GET("/rhythm-configs", middleware.RequireAdminPermission(h.Svc, admin.PermExploreRead), h.ListRhythmConfigs)
g.GET("/rhythm-configs/:id", middleware.RequireAdminPermission(h.Svc, admin.PermExploreRead), h.GetRhythmConfig)
}
func (h *AdminHandler) ListRhythmConfigs(c *gin.Context) {
items, err := h.Svc.ListRhythmConfigs(c.Request.Context())
if err != nil {
response.Fail(c, http.StatusInternalServerError, 50050, "list rhythm-config failed")
return
}
response.OK(c, gin.H{"items": items})
}
func (h *AdminHandler) GetRhythmConfig(c *gin.Context) {
id, err := uuid.Parse(c.Param("id"))
if err != nil {
response.Fail(c, http.StatusBadRequest, 40002, "invalid id")
return
}
row, err := h.Svc.GetRhythmConfig(c.Request.Context(), id)
if errors.Is(err, admin.ErrRhythmConfigNotFound) {
response.Fail(c, http.StatusNotFound, 40420, "rhythm-config not found")
return
}
if err != nil {
response.Fail(c, http.StatusInternalServerError, 50051, "get rhythm-config failed")
return
}
response.OK(c, row)
}