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

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

// V1BankCardInfoColumns defines and stores column names for the table bank_card_info.
type V1BankCardInfoColumns struct {
	Id              string // 主键，自增
	Uid             string // 唯一标识
	UserName        string // 用户名称
	BankName        string // 银行名称
	BankCode        string // 银行编码
	BankAccountType string // 银行账号类型
	AccountName     string // 银行账户名称
	BankNo          string // 银行账号
	IdentifyCard    string // 证件类型
	CertificateNo   string // 证件号码
	PhoneNo         string // 手机号码
	BankAddress     string // 银行地址
	CreateTime      string // 创建时间
	UpdateTime      string // 最近更新时间
}

// v1BankCardInfoColumns holds the columns for the table bank_card_info.
var v1BankCardInfoColumns = V1BankCardInfoColumns{
	Id:              "id",
	Uid:             "uid",
	UserName:        "user_name",
	BankName:        "bank_name",
	BankCode:        "bank_code",
	BankAccountType: "bank_account_type",
	AccountName:     "account_name",
	BankNo:          "bank_no",
	IdentifyCard:    "identify_card",
	CertificateNo:   "certificate_no",
	PhoneNo:         "phone_no",
	BankAddress:     "bank_address",
	CreateTime:      "create_time",
	UpdateTime:      "update_time",
}

// NewV1BankCardInfoDao creates and returns a new DAO object for table data access.
func NewV1BankCardInfoDao(handlers ...gdb.ModelHandler) *V1BankCardInfoDao {
	return &V1BankCardInfoDao{
		group:    "default",
		table:    "bank_card_info",
		columns:  v1BankCardInfoColumns,
		handlers: handlers,
	}
}

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

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

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

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