38 lines
1.3 KiB
Go
Executable File
38 lines
1.3 KiB
Go
Executable File
package model
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"fmt"
|
|
|
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
|
)
|
|
|
|
var _ WalletJournalModel = (*customWalletJournalModel)(nil)
|
|
|
|
type (
|
|
// WalletJournalModel is an interface to be customized, add more methods here,
|
|
// and implement the added methods in customWalletJournalModel.
|
|
WalletJournalModel interface {
|
|
walletJournalModel
|
|
InsertWithSession(ctx context.Context, tx sqlx.Session, data *WalletJournal) (sql.Result, error)
|
|
}
|
|
|
|
customWalletJournalModel struct {
|
|
*defaultWalletJournalModel
|
|
}
|
|
)
|
|
|
|
// NewWalletJournalModel returns a model for the database table.
|
|
func NewWalletJournalModel(conn sqlx.SqlConn) WalletJournalModel {
|
|
return &customWalletJournalModel{
|
|
defaultWalletJournalModel: newWalletJournalModel(conn),
|
|
}
|
|
}
|
|
|
|
func (m *customWalletJournalModel) InsertWithSession(ctx context.Context, tx sqlx.Session, data *WalletJournal) (sql.Result, error) {
|
|
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, walletJournalRowsExpectAutoSet)
|
|
ret, err := tx.ExecCtx(ctx, query, data.TransactionId, data.OrderId, data.Brand, data.Uid, data.WalletType, data.Currency, data.TransactionAmount, data.PostTransactionBalance, data.BusinessType, data.Status, data.DueTime, data.CreatedAt)
|
|
return ret, err
|
|
}
|