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

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

// V1MerchantInfoColumns defines and stores column names for the table merchant_info.
type V1MerchantInfoColumns struct {
	Id                   string // 主键，自增
	Status               string // 商户状态状态
	BelongAgentUid       string // 所属代理uid
	BelongAgentName      string // 所属代理名称
	MerchantName         string // 商户名称
	MerchantUid          string // 商户uid
	MerchantKey          string // 商户key
	MerchantSecret       string // 商户密钥
	LoginAccount         string // 登录账号
	LoginPassword        string // 登录密码
	AutoSettle           string // 是否自动结算
	AutoPayFor           string // 是否自动代付
	WhiteIps             string // 配置ip白名单
	Remark               string // 备注
	SinglePayForRoadUid  string // 单代付代付通道uid
	SinglePayForRoadName string // 单代付通道名称
	RollPayForRoadCode   string // 轮询代付通道编码
	RollPayForRoadName   string // 轮询代付通道名称
	PayforFee            string // 代付手续费
	UpdateTime           string // 更新时间
	CreateTime           string // 创建时间
	OtpSecret            string // 二次验证
}

// v1MerchantInfoColumns holds the columns for the table merchant_info.
var v1MerchantInfoColumns = V1MerchantInfoColumns{
	Id:                   "id",
	Status:               "status",
	BelongAgentUid:       "belong_agent_uid",
	BelongAgentName:      "belong_agent_name",
	MerchantName:         "merchant_name",
	MerchantUid:          "merchant_uid",
	MerchantKey:          "merchant_key",
	MerchantSecret:       "merchant_secret",
	LoginAccount:         "login_account",
	LoginPassword:        "login_password",
	AutoSettle:           "auto_settle",
	AutoPayFor:           "auto_pay_for",
	WhiteIps:             "white_ips",
	Remark:               "remark",
	SinglePayForRoadUid:  "single_pay_for_road_uid",
	SinglePayForRoadName: "single_pay_for_road_name",
	RollPayForRoadCode:   "roll_pay_for_road_code",
	RollPayForRoadName:   "roll_pay_for_road_name",
	PayforFee:            "payfor_fee",
	UpdateTime:           "update_time",
	CreateTime:           "create_time",
	OtpSecret:            "otp_secret",
}

// NewV1MerchantInfoDao creates and returns a new DAO object for table data access.
func NewV1MerchantInfoDao(handlers ...gdb.ModelHandler) *V1MerchantInfoDao {
	return &V1MerchantInfoDao{
		group:    "default",
		table:    "merchant_info",
		columns:  v1MerchantInfoColumns,
		handlers: handlers,
	}
}

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

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

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

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