bindbox-game/internal/api/user/address_share_revoke_app.go

41 lines
1.4 KiB
Go
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package app
import (
"net/http"
"bindbox-game/internal/code"
"bindbox-game/internal/pkg/core"
)
type addressShareRevokeRequest struct {
InventoryID int64 `json:"inventory_id"`
}
// RevokeAddressShare 撤销共享地址链接(极简方案,仅前端态)
// @Summary 撤销共享地址链接
// @Description 极简方案下为前端态操作:不落库令牌,撤销仅用于提示与禁用旧链接(可忽略服务端状态)
// @Tags APP端.用户
// @Accept json
// @Produce json
// @Param user_id path integer true "用户ID"
// @Security LoginVerifyToken
// @Param RequestBody body addressShareRevokeRequest true "请求参数资产ID"
// @Success 200 {object} okResponse
// @Failure 400 {object} code.Failure "参数错误"
// @Router /api/app/users/{user_id}/inventory/address-share/revoke [post]
func (h *handler) RevokeAddressShare() core.HandlerFunc {
return func(ctx core.Context) {
req := new(addressShareRevokeRequest)
if err := ctx.ShouldBindJSON(req); err != nil || req.InventoryID == 0 {
ctx.AbortWithError(core.Error(http.StatusBadRequest, code.ParamBindError, "参数错误"))
return
}
userID := int64(ctx.SessionUserInfo().Id)
if err := h.user.RevokeAddressShare(ctx.RequestContext(), userID, req.InventoryID); err != nil {
ctx.AbortWithError(core.Error(http.StatusBadRequest, 10021, err.Error()))
return
}
ctx.Payload(okResponse{Ok: true})
}
}