根据地址修复质押接口
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var _ NhNftHolderModel = (*customNhNftHolderModel)(nil)
|
||||
@@ -21,6 +22,7 @@ type (
|
||||
DeleteOtherUpdateSeq(ctx context.Context, updateSeq int) error
|
||||
FindTokensByAddress(ctx context.Context, address string) ([]string, error)
|
||||
HoldNft(ctx context.Context, uid uint) bool
|
||||
FindTokensByAddresses(ctx context.Context, addresses []string) ([]*NhNftHolder, error)
|
||||
}
|
||||
|
||||
customNhNftHolderModel struct {
|
||||
@@ -51,6 +53,24 @@ func (m *customNhNftHolderModel) FindTokensByAddress(ctx context.Context, addres
|
||||
return tokens, nil
|
||||
}
|
||||
|
||||
func (m *customNhNftHolderModel) FindTokensByAddresses(ctx context.Context, addresses []string) ([]*NhNftHolder, error) {
|
||||
// 生成占位符
|
||||
placeholders := make([]string, len(addresses))
|
||||
args := make([]interface{}, len(addresses))
|
||||
|
||||
for i, val := range addresses {
|
||||
placeholders[i] = "?"
|
||||
args[i] = val
|
||||
}
|
||||
query := fmt.Sprintf("select %s from %s where `address` in (%s)", nhNftHolderRows, m.table, strings.Join(placeholders, ","))
|
||||
var tokens []*NhNftHolder
|
||||
err := m.conn.QueryRowsCtx(ctx, &tokens, query, args...)
|
||||
if err != nil && !errors.Is(err, sqlx.ErrNotFound) {
|
||||
return nil, err
|
||||
}
|
||||
return tokens, nil
|
||||
}
|
||||
|
||||
func (m *customNhNftHolderModel) DeleteOtherUpdateSeq(ctx context.Context, updateSeq int) error {
|
||||
delSql := fmt.Sprintf("delete from %s where `update_seq` != ?", m.table)
|
||||
_, err := m.conn.ExecCtx(ctx, delSql, updateSeq)
|
||||
|
||||
Reference in New Issue
Block a user