41 lines
1.2 KiB
Go
41 lines
1.2 KiB
Go
package model
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
|
)
|
|
|
|
var _ NhCastileTokenModel = (*customNhCastileTokenModel)(nil)
|
|
|
|
type (
|
|
// NhCastileTokenModel is an interface to be customized, add more methods here,
|
|
// and implement the added methods in customNhCastileTokenModel.
|
|
NhCastileTokenModel interface {
|
|
nhCastileTokenModel
|
|
WithSession(session sqlx.Session) NhCastileTokenModel
|
|
UpdateTransferIncrease(ctx context.Context, reduce uint, id uint) error
|
|
}
|
|
|
|
customNhCastileTokenModel struct {
|
|
*defaultNhCastileTokenModel
|
|
}
|
|
)
|
|
|
|
// NewNhCastileTokenModel returns a model for the database table.
|
|
func NewNhCastileTokenModel(conn sqlx.SqlConn) NhCastileTokenModel {
|
|
return &customNhCastileTokenModel{
|
|
defaultNhCastileTokenModel: newNhCastileTokenModel(conn),
|
|
}
|
|
}
|
|
|
|
func (m *customNhCastileTokenModel) WithSession(session sqlx.Session) NhCastileTokenModel {
|
|
return NewNhCastileTokenModel(sqlx.NewSqlConnFromSession(session))
|
|
}
|
|
|
|
func (m *customNhCastileTokenModel) UpdateTransferIncrease(ctx context.Context, num uint, id uint) error {
|
|
query := fmt.Sprintf("update %s set `transfer` = `transfer` + ? where `id` = ?", m.table)
|
|
_, err := m.conn.ExecCtx(ctx, query, num, id)
|
|
return err
|
|
}
|