nft质押任务逻辑

This commit is contained in:
lianghuanjie
2024-12-27 18:06:13 +08:00
parent a22f73df20
commit 31a674080d
39 changed files with 1532 additions and 99 deletions

View File

@@ -17,6 +17,7 @@ type (
withSession(session sqlx.Session) NhNftHolderModel
FindOtherUpdateSeq(ctx context.Context, updateSeq int) ([]*NhNftHolder, error)
DeleteOtherUpdateSeq(ctx context.Context, updateSeq int) error
FindTokensByAddress(ctx context.Context, address string) ([]string, error)
}
customNhNftHolderModel struct {
@@ -24,6 +25,16 @@ type (
}
)
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
err := m.conn.QueryRowsCtx(ctx, &tokens, query, address)
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)