复用 admin.explore.write、POST/PUT+审计、C端 GET /cards/decks、 H5 无 active 空态/失败回退;migration 000054。无牌面内容编辑。 ExploreConfig Loop STOP,禁自动 ECR-046。 Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
958 B
Go
37 lines
958 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"
|
|
)
|
|
|
|
// ImageCardDeckPublicHandler serves GET /api/v1/cards/decks (DeviceAuth).
|
|
type ImageCardDeckPublicHandler struct {
|
|
Repo *repository.AdminRepo
|
|
}
|
|
|
|
// Register mounts public image card deck routes.
|
|
func (h *ImageCardDeckPublicHandler) Register(api *gin.RouterGroup) {
|
|
api.GET("/cards/decks", h.ListActive)
|
|
}
|
|
|
|
func (h *ImageCardDeckPublicHandler) ListActive(c *gin.Context) {
|
|
if h.Repo == nil {
|
|
response.OK(c, gin.H{"items": []repository.ImageCardDeckRow{}})
|
|
return
|
|
}
|
|
items, err := h.Repo.ListActiveImageCardDecks(c.Request.Context())
|
|
if err != nil {
|
|
response.Fail(c, http.StatusInternalServerError, 50054, "card decks failed")
|
|
return
|
|
}
|
|
if items == nil {
|
|
items = []repository.ImageCardDeckRow{}
|
|
}
|
|
response.OK(c, gin.H{"items": items})
|
|
}
|