重构(#4): 抽奖奖品改/删 id 走 URL path(RESTful)

- 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>
This commit is contained in:
2026-07-16 19:45:23 -07:00
parent abd8c068b6
commit 58c346abec
4 changed files with 17 additions and 8 deletions
@@ -2,6 +2,8 @@
package lottery
import (
"strconv"
"github.com/gin-gonic/gin"
adminlottery "github.com/perfect-panel/server/internal/logic/admin/lottery"
"github.com/perfect-panel/server/internal/svc"
@@ -118,6 +120,9 @@ func UpdateLotteryPrizeHandler(svcCtx *svc.ServiceContext) func(c *gin.Context)
return func(c *gin.Context) {
var req types.UpdateAdminLotteryPrizeRequest
_ = c.ShouldBind(&req)
if id, err := strconv.ParseInt(c.Param("id"), 10, 64); err == nil {
req.Id = id
}
if err := svcCtx.Validate(&req); err != nil {
result.ParamErrorResult(c, err)
return
@@ -132,6 +137,9 @@ func DeleteLotteryPrizeHandler(svcCtx *svc.ServiceContext) func(c *gin.Context)
return func(c *gin.Context) {
var req types.AdminPrizeIdRequest
_ = c.ShouldBind(&req)
if id, err := strconv.ParseInt(c.Param("id"), 10, 64); err == nil {
req.Id = id
}
if err := svcCtx.Validate(&req); err != nil {
result.ParamErrorResult(c, err)
return