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

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

// V1CardRedeemOrderInfoColumns defines and stores column names for the table card_redeem_order_info.
type V1CardRedeemOrderInfoColumns struct {
	OrderNo       string //
	CardNo        string // 卡号
	MerchantId    string //
	Attach        string //
	CreatedUserId string // 创建用户
	AccountId     string //
	AccountName   string // 账号名称
	GiftCardPwd   string // 卡密
	CardTypeName  string // 卡种
	NotifyUrl     string // 回调
	Remark        string // 备注
	OrderAmount   string // 订单金额
	ActualAmount  string // 实际金额
	Category      string // 账户类型
	CallbackCount string // 回调次数
	NotifyStatus  string // 回调状态 0没有回调 1.回调成功 2.回调失败
	Status        string // 1.兑换成功 0.失败
	OrderStatus   string // 订单状态 订单原本状态
	CreatedAt     string //
	UpdatedAt     string //
	DeletedAt     string //
}

// v1CardRedeemOrderInfoColumns holds the columns for the table card_redeem_order_info.
var v1CardRedeemOrderInfoColumns = V1CardRedeemOrderInfoColumns{
	OrderNo:       "order_no",
	CardNo:        "card_no",
	MerchantId:    "merchant_id",
	Attach:        "attach",
	CreatedUserId: "created_user_id",
	AccountId:     "account_id",
	AccountName:   "account_name",
	GiftCardPwd:   "gift_card_pwd",
	CardTypeName:  "card_type_name",
	NotifyUrl:     "notify_url",
	Remark:        "remark",
	OrderAmount:   "order_amount",
	ActualAmount:  "actual_amount",
	Category:      "category",
	CallbackCount: "callback_count",
	NotifyStatus:  "notify_status",
	Status:        "status",
	OrderStatus:   "order_status",
	CreatedAt:     "created_at",
	UpdatedAt:     "updated_at",
	DeletedAt:     "deleted_at",
}

// NewV1CardRedeemOrderInfoDao creates and returns a new DAO object for table data access.
func NewV1CardRedeemOrderInfoDao(handlers ...gdb.ModelHandler) *V1CardRedeemOrderInfoDao {
	return &V1CardRedeemOrderInfoDao{
		group:    "default",
		table:    "card_redeem_order_info",
		columns:  v1CardRedeemOrderInfoColumns,
		handlers: handlers,
	}
}

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

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

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

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