增加统一加资产接口
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
)
|
||||
|
||||
@@ -18,6 +20,7 @@ type (
|
||||
FindOtherUpdateSeq(ctx context.Context, updateSeq int) ([]*NhNftHolder, error)
|
||||
DeleteOtherUpdateSeq(ctx context.Context, updateSeq int) error
|
||||
FindTokensByAddress(ctx context.Context, address string) ([]string, error)
|
||||
HoldNft(ctx context.Context, uid uint) bool
|
||||
}
|
||||
|
||||
customNhNftHolderModel struct {
|
||||
@@ -25,6 +28,19 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func (m *customNhNftHolderModel) HoldNft(ctx context.Context, uid uint) bool {
|
||||
query := fmt.Sprintf("select count(1) from %s h join nh_wallet w on h.address = w.address where w.`uid` = ?", m.table)
|
||||
var count int
|
||||
err := m.conn.QueryRowCtx(ctx, &count, query, uid)
|
||||
if err != nil {
|
||||
if !errors.Is(err, sqlc.ErrNotFound) {
|
||||
logx.Errorw("HoldNft query failed", logx.Field("query", query), logx.Field("args", uid), logx.Field("err", err))
|
||||
}
|
||||
return false
|
||||
}
|
||||
return count > 0
|
||||
}
|
||||
|
||||
func (m *customNhNftHolderModel) FindTokensByAddress(ctx context.Context, address string) ([]string, error) {
|
||||
query := fmt.Sprintf("select `token_id` from %s where `address` = ?", m.table)
|
||||
var tokens []string
|
||||
|
||||
Reference in New Issue
Block a user