// ==========================================================================
// 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"
)

// V1AccountInfoDao is the data access object for the table account_info.
type V1AccountInfoDao 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  V1AccountInfoColumns // columns contains all the column names of Table for convenient usage.
	handlers []gdb.ModelHandler   // handlers for customized model modification.
}

// V1AccountInfoColumns defines and stores column names for the table account_info.
type V1AccountInfoColumns struct {
	Id           string // 主键，自增
	Status       string // 状态
	AccountUid   string // 账户uid，对应为merchant_uid或者agent_uid
	AccountName  string // 账户名称，对应的是merchant_name或者agent_name
	Balance      string // 账户余额
	SettleAmount string // 已经结算了的金额
	LoanAmount   string // 押款金额
	WaitAmount   string // 待结算资金
	FreezeAmount string // 账户冻结金额
	PayforAmount string // 账户代付中金额
	UpdateTime   string // 更新时间
	CreateTime   string // 创建时间
}

// v1AccountInfoColumns holds the columns for the table account_info.
var v1AccountInfoColumns = V1AccountInfoColumns{
	Id:           "id",
	Status:       "status",
	AccountUid:   "account_uid",
	AccountName:  "account_name",
	Balance:      "balance",
	SettleAmount: "settle_amount",
	LoanAmount:   "loan_amount",
	WaitAmount:   "wait_amount",
	FreezeAmount: "freeze_amount",
	PayforAmount: "payfor_amount",
	UpdateTime:   "update_time",
	CreateTime:   "create_time",
}

// NewV1AccountInfoDao creates and returns a new DAO object for table data access.
func NewV1AccountInfoDao(handlers ...gdb.ModelHandler) *V1AccountInfoDao {
	return &V1AccountInfoDao{
		group:    "default",
		table:    "account_info",
		columns:  v1AccountInfoColumns,
		handlers: handlers,
	}
}

// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *V1AccountInfoDao) DB() gdb.DB {
	return g.DB(dao.group)
}

// Table returns the table name of the current DAO.
func (dao *V1AccountInfoDao) Table() string {
	return dao.table
}

// Columns returns all column names of the current DAO.
func (dao *V1AccountInfoDao) Columns() V1AccountInfoColumns {
	return dao.columns
}

// Group returns the database configuration group name of the current DAO.
func (dao *V1AccountInfoDao) 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 *V1AccountInfoDao) 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 *V1AccountInfoDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
	return dao.Ctx(ctx).Transaction(ctx, f)
}
