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

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

// V1CardAppleRechargeInfoColumns defines and stores column names for the table card_apple_recharge_info.
type V1CardAppleRechargeInfoColumns struct {
	Id                string //
	OrderNo           string // 订单号
	AccountId         string //
	AccountName       string //
	CardNo            string // 卡号
	CardPass          string // 卡密
	MerchantId        string // 商户ID
	Balance           string // 余额
	CardAmount        string // 卡面充值金额
	NotifyStatus      string //
	Status            string // 状态 0.创建 1.交易成功 2.交易中 3.交易失败
	ActualAmount      string // 实际充值金额
	CallbackUrl       string //
	CallbackCount     string // itunes回调次数
	DistributionCount string //
	CreatedUserId     string // 创建者ID
	Attach            string //
	Remark            string //
	CreatedAt         string // 创建日期
	UpdatedAt         string // 更新日期
	DeletedAt         string // 删除日期
}

// v1CardAppleRechargeInfoColumns holds the columns for the table card_apple_recharge_info.
var v1CardAppleRechargeInfoColumns = V1CardAppleRechargeInfoColumns{
	Id:                "id",
	OrderNo:           "order_no",
	AccountId:         "account_id",
	AccountName:       "account_name",
	CardNo:            "card_no",
	CardPass:          "card_pass",
	MerchantId:        "merchant_id",
	Balance:           "balance",
	CardAmount:        "card_amount",
	NotifyStatus:      "notify_status",
	Status:            "status",
	ActualAmount:      "actual_amount",
	CallbackUrl:       "callback_url",
	CallbackCount:     "callback_count",
	DistributionCount: "distribution_count",
	CreatedUserId:     "created_user_id",
	Attach:            "attach",
	Remark:            "remark",
	CreatedAt:         "created_at",
	UpdatedAt:         "updated_at",
	DeletedAt:         "deleted_at",
}

// NewV1CardAppleRechargeInfoDao creates and returns a new DAO object for table data access.
func NewV1CardAppleRechargeInfoDao(handlers ...gdb.ModelHandler) *V1CardAppleRechargeInfoDao {
	return &V1CardAppleRechargeInfoDao{
		group:    "default",
		table:    "card_apple_recharge_info",
		columns:  v1CardAppleRechargeInfoColumns,
		handlers: handlers,
	}
}

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

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

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

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