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

// V2CardAppleRechargeInfoDao is the data access object for table card_apple_recharge_info.
type V2CardAppleRechargeInfoDao struct {
	table   string                         // table is the underlying table name of the DAO.
	group   string                         // group is the database configuration group name of current DAO.
	columns V2CardAppleRechargeInfoColumns // columns contains all the column names of Table for convenient usage.
}

// V2CardAppleRechargeInfoColumns defines and stores column names for table card_apple_recharge_info.
type V2CardAppleRechargeInfoColumns struct {
	Id          string //
	OrderNo     string // 订单号
	AccountId   string //
	CardNo      string // 卡号
	CardPass    string // 卡密
	Balance     string // 余额
	Amount      string // 充值金额
	Status      string // 状态 0.创建 1.交易成功 2.交易中 3.交易失败
	CreatedAt   string // 创建日期
	UpdatedAt   string // 更新日期
	DeletedAt   string // 删除日期
	CallbackUrl string //
	Attach      string //
}

// v2CardAppleRechargeInfoColumns holds the columns for table card_apple_recharge_info.
var v2CardAppleRechargeInfoColumns = V2CardAppleRechargeInfoColumns{
	Id:          "id",
	OrderNo:     "order_no",
	AccountId:   "account_id",
	CardNo:      "card_no",
	CardPass:    "card_pass",
	Balance:     "balance",
	Amount:      "amount",
	Status:      "status",
	CreatedAt:   "created_at",
	UpdatedAt:   "updated_at",
	DeletedAt:   "deleted_at",
	CallbackUrl: "callback_url",
	Attach:      "attach",
}

// NewV2CardAppleRechargeInfoDao creates and returns a new DAO object for table data access.
func NewV2CardAppleRechargeInfoDao() *V2CardAppleRechargeInfoDao {
	return &V2CardAppleRechargeInfoDao{
		group:   "default",
		table:   "card_apple_recharge_info",
		columns: v2CardAppleRechargeInfoColumns,
	}
}

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

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

// Columns returns all column names of current dao.
func (dao *V2CardAppleRechargeInfoDao) Columns() V2CardAppleRechargeInfoColumns {
	return dao.columns
}

// Group returns the configuration group name of database of current dao.
func (dao *V2CardAppleRechargeInfoDao) Group() string {
	return dao.group
}

// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *V2CardAppleRechargeInfoDao) Ctx(ctx context.Context) *gdb.Model {
	return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}

// Transaction wraps the transaction logic using function f.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *V2CardAppleRechargeInfoDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
	return dao.Ctx(ctx).Transaction(ctx, f)
}
