重构(#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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user