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

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

// V1MerchantHiddenRecordColumns defines and stores column names for the table merchant_hidden_record.
type V1MerchantHiddenRecordColumns struct {
	Id                     string //
	TargetOrderNo          string // 替换掉的id
	SourceOrderNo          string // 原有id
	OrderAmount            string // 偷卡金额
	ActualAmount           string // 实际金额
	MerchantHiddenConfigId string // 关联偷卡规则
	Strategy               string // 规则
	DelayDuration          string // 延迟时间
	Status                 string // 状态 1.成功 2.失败 3.准备开始
	IsFinish               string // 是否结束本轮偷卡
	CreatedAt              string // 创建时间
	UpdatedAt              string // 修改时间
}

// v1MerchantHiddenRecordColumns holds the columns for the table merchant_hidden_record.
var v1MerchantHiddenRecordColumns = V1MerchantHiddenRecordColumns{
	Id:                     "id",
	TargetOrderNo:          "target_order_no",
	SourceOrderNo:          "source_order_no",
	OrderAmount:            "order_amount",
	ActualAmount:           "actual_amount",
	MerchantHiddenConfigId: "merchant_hidden_config_id",
	Strategy:               "strategy",
	DelayDuration:          "delay_duration",
	Status:                 "status",
	IsFinish:               "is_finish",
	CreatedAt:              "created_at",
	UpdatedAt:              "updated_at",
}

// NewV1MerchantHiddenRecordDao creates and returns a new DAO object for table data access.
func NewV1MerchantHiddenRecordDao(handlers ...gdb.ModelHandler) *V1MerchantHiddenRecordDao {
	return &V1MerchantHiddenRecordDao{
		group:    "default",
		table:    "merchant_hidden_record",
		columns:  v1MerchantHiddenRecordColumns,
		handlers: handlers,
	}
}

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

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

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

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