feat(ECR-012–016): 合规、题库、时辰刷新、头像、MBTI OEJTS 与埋点
落地输入合规、探索题库、报告日/时辰刷新、账号头像、OEJTS 量表,并补齐 H5 埋点与 Admin 漏斗;同步 ESS 工件、切至自建 Git、清理 GitHub Actions。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,11 +6,14 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/yuxingu/digital-psychology/apps/api/internal/explore"
|
||||
"github.com/yuxingu/digital-psychology/apps/api/internal/service/scale"
|
||||
"github.com/yuxingu/digital-psychology/apps/api/pkg/response"
|
||||
)
|
||||
|
||||
// ExploreHandler serves the explore catalog.
|
||||
type ExploreHandler struct{}
|
||||
type ExploreHandler struct {
|
||||
Scales *scale.Service
|
||||
}
|
||||
|
||||
// Register mounts explore routes.
|
||||
func (h *ExploreHandler) Register(rg *gin.RouterGroup) {
|
||||
@@ -20,7 +23,13 @@ func (h *ExploreHandler) Register(rg *gin.RouterGroup) {
|
||||
|
||||
// Catalog handles GET /explore/catalog.
|
||||
func (h *ExploreHandler) Catalog(c *gin.Context) {
|
||||
response.OK(c, gin.H{"categories": explore.Catalog()})
|
||||
cats := explore.Catalog()
|
||||
if h.Scales != nil {
|
||||
if items, err := h.Scales.List(c.Request.Context()); err == nil {
|
||||
cats = explore.WithPublishedScales(cats, items)
|
||||
}
|
||||
}
|
||||
response.OK(c, gin.H{"categories": cats})
|
||||
}
|
||||
|
||||
// Category handles GET /explore/catalog/:key.
|
||||
@@ -30,5 +39,14 @@ func (h *ExploreHandler) Category(c *gin.Context) {
|
||||
response.Fail(c, http.StatusNotFound, 40402, "category not found")
|
||||
return
|
||||
}
|
||||
if cat.Key == "tests" && h.Scales != nil {
|
||||
if items, err := h.Scales.List(c.Request.Context()); err == nil {
|
||||
enriched := explore.WithPublishedScales([]explore.Category{*cat}, items)
|
||||
if len(enriched) > 0 {
|
||||
response.OK(c, enriched[0])
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
response.OK(c, cat)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user