Files
olons_admin/server/internal/dao/internal/wallet_ledger.go
T
2026-10-10 20:56:17 +08:00

116 lines
4.0 KiB
Go

// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// WalletLedgerDao is the data access object for the table hg_wallet_ledger.
type WalletLedgerDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns WalletLedgerColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// WalletLedgerColumns defines and stores column names for the table hg_wallet_ledger.
type WalletLedgerColumns struct {
Id string // 主键
TenantId string // 租户ID
LedgerNo string // 账变流水号
AccountId string // 钱包账户ID
MemberId string // 会员ID
BizType string // 业务类型
BizNo string // 业务单号
EntryType string // 账变类型
Direction string // 方向 1收入 2支出
Amount string // 发生金额(分)
BeforeAmount string // 变更前余额(分)
AfterAmount string // 变更后余额(分)
Currency string // 币种
ReversalOf string // 冲正原流水ID
IdempotencyKey string // 幂等键
Remark string // 说明
OperatorId string // 操作人
OccurredAt string // 发生时间
CreatedAt string // 创建时间
}
// walletLedgerColumns holds the columns for the table hg_wallet_ledger.
var walletLedgerColumns = WalletLedgerColumns{
Id: "id",
TenantId: "tenant_id",
LedgerNo: "ledger_no",
AccountId: "account_id",
MemberId: "member_id",
BizType: "biz_type",
BizNo: "biz_no",
EntryType: "entry_type",
Direction: "direction",
Amount: "amount",
BeforeAmount: "before_amount",
AfterAmount: "after_amount",
Currency: "currency",
ReversalOf: "reversal_of",
IdempotencyKey: "idempotency_key",
Remark: "remark",
OperatorId: "operator_id",
OccurredAt: "occurred_at",
CreatedAt: "created_at",
}
// NewWalletLedgerDao creates and returns a new DAO object for table data access.
func NewWalletLedgerDao(handlers ...gdb.ModelHandler) *WalletLedgerDao {
return &WalletLedgerDao{
group: "default",
table: "hg_wallet_ledger",
columns: walletLedgerColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *WalletLedgerDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *WalletLedgerDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *WalletLedgerDao) Columns() WalletLedgerColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *WalletLedgerDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *WalletLedgerDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *WalletLedgerDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}