e8e3a3a72b
- 分页列出 lottery_draw,join 奖品快照 + 用户邮箱 + 发放账本(grant_ledger) - 支持 activity/user/win/dispatch_state/prize_type/时间窗过滤 - 展示中奖人/奖品/发放状态/发放结果(如"已新建订阅并加 30 天") Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
55 lines
2.9 KiB
Go
55 lines
2.9 KiB
Go
package handler
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
adminLottery "github.com/perfect-panel/server/internal/handler/admin/lottery"
|
|
publicLottery "github.com/perfect-panel/server/internal/handler/public/lottery"
|
|
"github.com/perfect-panel/server/internal/middleware"
|
|
"github.com/perfect-panel/server/internal/svc"
|
|
)
|
|
|
|
// registerLotteryRoutes wires the Stage 1 lottery endpoints. Kept in its own
|
|
// file to avoid ballooning routes.go and to make the lottery surface easy to
|
|
// audit end-to-end. The path prefix "/v1/lottery" is under the user middleware
|
|
// stack (AuthMiddleware + DeviceMiddleware); "/v1/admin/lottery" uses the
|
|
// admin-detecting AuthMiddleware (path contains "admin" segment).
|
|
func registerLotteryRoutes(router *gin.Engine, serverCtx *svc.ServiceContext) {
|
|
userGroup := router.Group("/v1/lottery")
|
|
userGroup.Use(middleware.AuthMiddleware(serverCtx), middleware.DeviceMiddleware(serverCtx))
|
|
{
|
|
userGroup.GET("/config", publicLottery.QueryLotteryConfigHandler(serverCtx))
|
|
userGroup.POST("/draw", publicLottery.DrawLotteryHandler(serverCtx))
|
|
userGroup.GET("/records", publicLottery.QueryLotteryRecordsHandler(serverCtx))
|
|
userGroup.POST("/claim", publicLottery.ClaimLotteryPrizeHandler(serverCtx))
|
|
}
|
|
|
|
adminGroup := router.Group("/v1/admin/lottery")
|
|
adminGroup.Use(middleware.AuthMiddleware(serverCtx), middleware.AdminMetaMiddleware())
|
|
{
|
|
adminGroup.POST("/activities", adminLottery.CreateLotteryActivityHandler(serverCtx))
|
|
adminGroup.PUT("/activities", adminLottery.UpdateLotteryActivityHandler(serverCtx))
|
|
adminGroup.GET("/activities", adminLottery.ListLotteryActivitiesHandler(serverCtx))
|
|
adminGroup.GET("/activities/detail", adminLottery.GetLotteryActivityHandler(serverCtx))
|
|
adminGroup.POST("/activities/publish", adminLottery.PublishLotteryActivityHandler(serverCtx))
|
|
adminGroup.POST("/activities/pause", adminLottery.PauseLotteryActivityHandler(serverCtx))
|
|
adminGroup.PUT("/activities/rules", adminLottery.UpdateLotteryRulesHandler(serverCtx))
|
|
|
|
adminGroup.POST("/prizes", adminLottery.CreateLotteryPrizeHandler(serverCtx))
|
|
adminGroup.PUT("/prizes/:id", adminLottery.UpdateLotteryPrizeHandler(serverCtx))
|
|
adminGroup.DELETE("/prizes/:id", adminLottery.DeleteLotteryPrizeHandler(serverCtx))
|
|
adminGroup.GET("/prizes", adminLottery.ListLotteryPrizesHandler(serverCtx))
|
|
|
|
adminGroup.POST("/chances/grant", adminLottery.GrantLotteryChanceHandler(serverCtx))
|
|
|
|
// Stage 2 (HIF-4): 人工奖工单接口
|
|
adminGroup.GET("/claims", adminLottery.ListLotteryClaimsHandler(serverCtx))
|
|
adminGroup.GET("/claims/summary", adminLottery.LotteryClaimsSummaryHandler(serverCtx))
|
|
adminGroup.POST("/claims/approve", adminLottery.ApproveLotteryClaimHandler(serverCtx))
|
|
adminGroup.POST("/claims/reject", adminLottery.RejectLotteryClaimHandler(serverCtx))
|
|
adminGroup.POST("/claims/mark-paid", adminLottery.MarkPaidLotteryClaimHandler(serverCtx))
|
|
|
|
// Stage 3: 抽奖记录(发放流水)
|
|
adminGroup.GET("/draws", adminLottery.ListLotteryDrawsHandler(serverCtx))
|
|
}
|
|
}
|