package tokenservicelogic import ( ers "code.30cm.net/wanderland/library-go/errors" "context" "ark-permission/gen_result/pb/permission" "ark-permission/internal/svc" "github.com/zeromicro/go-zero/core/logx" ) type CancelOneTimeTokenLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewCancelOneTimeTokenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CancelOneTimeTokenLogic { return &CancelOneTimeTokenLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } type cancelOneTimeTokenReq struct { Token []string `json:"token" validate:"required"` } // CancelOneTimeToken 取消一次性使用 func (l *CancelOneTimeTokenLogic) CancelOneTimeToken(in *permission.CancelOneTimeTokenReq) (*permission.OKResp, error) { // 驗證所需 if err := l.svcCtx.Validate.ValidateAll(&cancelOneTimeTokenReq{ Token: in.GetToken(), }); err != nil { return nil, ers.InvalidFormat(err.Error()) } err := l.svcCtx.TokenRedisRepo.DeleteOneTimeToken(l.ctx, in.GetToken(), nil) if err != nil { return nil, err } return &permission.OKResp{}, nil }