// Package lottery contains the user-facing lottery HTTP handlers. Each handler // binds request params via gin, validates, delegates to the logic package, // and renders through pkg/result to keep the API response envelope consistent. package lottery import ( "github.com/gin-gonic/gin" "github.com/perfect-panel/server/internal/logic/public/lottery" "github.com/perfect-panel/server/internal/svc" "github.com/perfect-panel/server/internal/types" "github.com/perfect-panel/server/pkg/result" ) // QueryLotteryConfigHandler serves GET /api/v1/lottery/config. func QueryLotteryConfigHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) { return func(c *gin.Context) { var req types.GetLotteryConfigRequest _ = c.ShouldBind(&req) if err := svcCtx.Validate(&req); err != nil { result.ParamErrorResult(c, err) return } l := lottery.NewQueryLotteryConfigLogic(c.Request.Context(), svcCtx) resp, err := l.QueryLotteryConfig(&req) result.HttpResult(c, resp, err) } } // DrawLotteryHandler serves POST /api/v1/lottery/draw. func DrawLotteryHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) { return func(c *gin.Context) { var req types.DrawLotteryRequest _ = c.ShouldBind(&req) if err := svcCtx.Validate(&req); err != nil { result.ParamErrorResult(c, err) return } l := lottery.NewDrawLotteryLogic(c.Request.Context(), svcCtx) resp, err := l.DrawLottery(&req) result.HttpResult(c, resp, err) } } // QueryLotteryRecordsHandler serves GET /api/v1/lottery/records. func QueryLotteryRecordsHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) { return func(c *gin.Context) { var req types.GetLotteryRecordsRequest _ = c.ShouldBind(&req) l := lottery.NewQueryLotteryRecordsLogic(c.Request.Context(), svcCtx) resp, err := l.QueryLotteryRecords(&req) result.HttpResult(c, resp, err) } } // ClaimLotteryPrizeHandler serves POST /api/v1/lottery/claim. Stage 1 // always returns 4010 not_claimable. func ClaimLotteryPrizeHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) { return func(c *gin.Context) { var req types.ClaimLotteryPrizeRequest _ = c.ShouldBind(&req) if err := svcCtx.Validate(&req); err != nil { result.ParamErrorResult(c, err) return } l := lottery.NewClaimLotteryPrizeLogic(c.Request.Context(), svcCtx) resp, err := l.ClaimLotteryPrize(&req) result.HttpResult(c, resp, err) } }