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

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

// V1CardAppleAccountInfoColumns defines and stores column names for the table card_apple_account_info.
type V1CardAppleAccountInfoColumns struct {
	Id                    string // 主键
	Account               string // 账户
	Password              string // 密码
	Balance               string // 余额
	BalanceItunes         string // itunes充值后余额
	Status                string // 状态 0.停用 1.正常使用（待充值） 2.正在充值 3.已达到单日充值限制
	TodayRechargeAmount   string // 今日充值金额，临时字段，方便查询
	TodayRechargeCount    string // 今日充值笔数，临时字段，方便查询
	TodayRechargeDatetime string // 今日日期，临时字段，方便查询
	CreatedUserId         string //
	CreatedUserRole       string //
	MaxAmountLimit        string // 最大充值限制金额
	MaxCountLimit         string // 最大充值限制次数
	Remark                string // 备注
	CreatedAt             string // 创建日期
	UpdatedAt             string // 更新日期
	DeletedAt             string // 删除日期
}

// v1CardAppleAccountInfoColumns holds the columns for the table card_apple_account_info.
var v1CardAppleAccountInfoColumns = V1CardAppleAccountInfoColumns{
	Id:                    "id",
	Account:               "account",
	Password:              "password",
	Balance:               "balance",
	BalanceItunes:         "balance_itunes",
	Status:                "status",
	TodayRechargeAmount:   "today_recharge_amount",
	TodayRechargeCount:    "today_recharge_count",
	TodayRechargeDatetime: "today_recharge_datetime",
	CreatedUserId:         "created_user_id",
	CreatedUserRole:       "created_user_role",
	MaxAmountLimit:        "max_amount_limit",
	MaxCountLimit:         "max_count_limit",
	Remark:                "remark",
	CreatedAt:             "created_at",
	UpdatedAt:             "updated_at",
	DeletedAt:             "deleted_at",
}

// NewV1CardAppleAccountInfoDao creates and returns a new DAO object for table data access.
func NewV1CardAppleAccountInfoDao(handlers ...gdb.ModelHandler) *V1CardAppleAccountInfoDao {
	return &V1CardAppleAccountInfoDao{
		group:    "default",
		table:    "card_apple_account_info",
		columns:  v1CardAppleAccountInfoColumns,
		handlers: handlers,
	}
}

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

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

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

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