58c346abec
- PUT /admin/lottery/prizes/:id、DELETE /admin/lottery/prizes/:id
- handler 从 c.Param("id") 取 id;types 用 path:"id"
- 同步 apis/admin/lottery.api 定义
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
52 lines
2.8 KiB
Go
52 lines
2.8 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))
|
|
}
|
|
}
|