完善数据上报,每日支付任务认证
This commit is contained in:
41
internal/model/nh_wallet_model.go
Executable file
41
internal/model/nh_wallet_model.go
Executable file
@@ -0,0 +1,41 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
)
|
||||
|
||||
var _ NhWalletModel = (*customNhWalletModel)(nil)
|
||||
|
||||
type (
|
||||
// NhWalletModel is an interface to be customized, add more methods here,
|
||||
// and implement the added methods in customNhWalletModel.
|
||||
NhWalletModel interface {
|
||||
nhWalletModel
|
||||
withSession(session sqlx.Session) NhWalletModel
|
||||
FindWalletByAddress(ctx context.Context, address ...string) (uint, error)
|
||||
}
|
||||
|
||||
customNhWalletModel struct {
|
||||
*defaultNhWalletModel
|
||||
}
|
||||
)
|
||||
|
||||
func (m *customNhWalletModel) FindWalletByAddress(ctx context.Context, address ...string) (uint, error) {
|
||||
query := fmt.Sprintf("select `uid` from %s where `address` in ? limit 1", m.table)
|
||||
var uid uint
|
||||
err := m.conn.QueryRowCtx(ctx, &uid, query, address)
|
||||
return uid, err
|
||||
}
|
||||
|
||||
// NewNhWalletModel returns a model for the database table.
|
||||
func NewNhWalletModel(conn sqlx.SqlConn) NhWalletModel {
|
||||
return &customNhWalletModel{
|
||||
defaultNhWalletModel: newNhWalletModel(conn),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *customNhWalletModel) withSession(session sqlx.Session) NhWalletModel {
|
||||
return NewNhWalletModel(sqlx.NewSqlConnFromSession(session))
|
||||
}
|
||||
Reference in New Issue
Block a user