nft质押任务逻辑
This commit is contained in:
36
internal/logic/task/stake_nft_logic.go
Normal file
36
internal/logic/task/stake_nft_logic.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
"nova_task/internal/pkg/errs"
|
||||
"nova_task/internal/pkg/utils"
|
||||
"nova_task/internal/svc"
|
||||
"nova_task/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type StakeNftLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewStakeNftLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StakeNftLogic {
|
||||
return &StakeNftLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *StakeNftLogic) StakeNft(req *types.StakeNftList) error {
|
||||
uid := utils.GetUidUint(l.ctx)
|
||||
err := l.svcCtx.StakeNftModel.StakeNft(l.ctx, uid, req.TokenIds)
|
||||
if err != nil {
|
||||
l.Errorw("stake nft failed", logx.Field("err", err), logx.Field("uid", uid), logx.Field("tokenIds", req.TokenIds))
|
||||
return errs.New(errs.ErrDatabaseOperate, err)
|
||||
}
|
||||
|
||||
return errs.Success()
|
||||
}
|
||||
Reference in New Issue
Block a user