Files
digital-psychology/apps/api/internal/handler/explore.go
T
jackyu66gitandCursor bd22d9dddd feat: P1 合盘/星座/问答与测测完整设计包及模拟器取证工具
落地 synastry/star/ask API 与 H5 页面,补齐 cece-frontend-re complete-design 证据文档,并加入 Android 模拟器截图抓取脚本。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-03 11:37:53 +08:00

35 lines
873 B
Go

package handler
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/yuxingu/digital-psychology/apps/api/internal/explore"
"github.com/yuxingu/digital-psychology/apps/api/pkg/response"
)
// ExploreHandler serves the explore catalog.
type ExploreHandler struct{}
// Register mounts explore routes.
func (h *ExploreHandler) Register(rg *gin.RouterGroup) {
rg.GET("/explore/catalog", h.Catalog)
rg.GET("/explore/catalog/:key", h.Category)
}
// Catalog handles GET /explore/catalog.
func (h *ExploreHandler) Catalog(c *gin.Context) {
response.OK(c, gin.H{"categories": explore.Catalog()})
}
// Category handles GET /explore/catalog/:key.
func (h *ExploreHandler) Category(c *gin.Context) {
cat := explore.CategoryByKey(c.Param("key"))
if cat == nil {
response.Fail(c, http.StatusNotFound, 40402, "category not found")
return
}
response.OK(c, cat)
}