2024-10-29 08:17:31 +00:00
|
|
|
package model
|
|
|
|
|
2024-10-30 11:13:56 +00:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"database/sql"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
|
|
|
)
|
2024-10-29 08:17:31 +00:00
|
|
|
|
|
|
|
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
|
2024-10-30 11:13:56 +00:00
|
|
|
InsertWithSession(ctx context.Context, tx sqlx.Session, data *WalletJournal) (sql.Result, error)
|
2024-10-29 08:17:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
customWalletJournalModel struct {
|
|
|
|
*defaultWalletJournalModel
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
// NewWalletJournalModel returns a model for the database table.
|
|
|
|
func NewWalletJournalModel(conn sqlx.SqlConn) WalletJournalModel {
|
|
|
|
return &customWalletJournalModel{
|
|
|
|
defaultWalletJournalModel: newWalletJournalModel(conn),
|
|
|
|
}
|
|
|
|
}
|
2024-10-30 11:13:56 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|