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

@@ -0,0 +1,44 @@
package model
import (
"context"
"fmt"
"github.com/zeromicro/go-zero/core/stores/sqlx"
)
var _ NhGamePitModel = (*customNhGamePitModel)(nil)
type (
// NhGamePitModel is an interface to be customized, add more methods here,
// and implement the added methods in customNhGamePitModel.
NhGamePitModel interface {
nhGamePitModel
withSession(session sqlx.Session) NhGamePitModel
UserExist(ctx context.Context, uid uint) bool
}
customNhGamePitModel struct {
*defaultNhGamePitModel
}
)
func (m *customNhGamePitModel) UserExist(ctx context.Context, uid uint) bool {
query := fmt.Sprintf("SELECT `id` FROM %s WHERE `uid` = ? LIMIT 1", m.table)
var id int
err := m.conn.QueryRowCtx(ctx, &id, query, uid)
if err != nil {
return false
}
return id > 0
}
// NewNhGamePitModel returns a model for the database table.
func NewNhGamePitModel(conn sqlx.SqlConn) NhGamePitModel {
return &customNhGamePitModel{
defaultNhGamePitModel: newNhGamePitModel(conn),
}
}
func (m *customNhGamePitModel) withSession(session sqlx.Session) NhGamePitModel {
return NewNhGamePitModel(sqlx.NewSqlConnFromSession(session))
}