nft质押任务逻辑
This commit is contained in:
44
internal/model/nh_game_pit_model.go
Executable file
44
internal/model/nh_game_pit_model.go
Executable 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))
|
||||
}
|
||||
Reference in New Issue
Block a user