39 lines
1.0 KiB
Go
39 lines
1.0 KiB
Go
package app
|
|
|
|
import (
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"bindbox-game/internal/code"
|
|
"bindbox-game/internal/pkg/core"
|
|
)
|
|
|
|
func (h *handler) GetPendingPrizeGrantActivity() core.HandlerFunc {
|
|
return func(ctx core.Context) {
|
|
userID := int64(ctx.SessionUserInfo().Id)
|
|
res, err := h.prizeGrant.GetPendingActivity(ctx.RequestContext(), userID)
|
|
if err != nil {
|
|
ctx.AbortWithError(core.Error(http.StatusBadRequest, code.GetActivityError, err.Error()))
|
|
return
|
|
}
|
|
ctx.Payload(res)
|
|
}
|
|
}
|
|
|
|
func (h *handler) ClaimPrizeGrantActivity() core.HandlerFunc {
|
|
return func(ctx core.Context) {
|
|
activityID, err := strconv.ParseInt(ctx.Param("id"), 10, 64)
|
|
if err != nil || activityID <= 0 {
|
|
ctx.AbortWithError(core.Error(http.StatusBadRequest, code.ParamBindError, "活动ID无效"))
|
|
return
|
|
}
|
|
userID := int64(ctx.SessionUserInfo().Id)
|
|
res, err := h.prizeGrant.ClaimActivity(ctx.RequestContext(), activityID, userID)
|
|
if err != nil {
|
|
ctx.AbortWithError(core.Error(http.StatusBadRequest, code.ModifyActivityError, err.Error()))
|
|
return
|
|
}
|
|
ctx.Payload(res)
|
|
}
|
|
}
|