package system

import "context"

// AutoCodeAdapter 自动代码数据库适配器接口
type AutoCodeAdapter interface {
	// GetDB 获取所有数据库
	GetDB(ctx context.Context) ([]Db, error)
	// GetTables 获取指定数据库的所有表
	GetTables(ctx context.Context, dbName string) ([]Table, error)
	// GetColumn 获取指定表的所有列
	GetColumn(ctx context.Context, tableName, dbName string) ([]Column, error)
}

// AutoCodeAdapterFactory 适配器工厂
type AutoCodeAdapterFactory struct {
	adapters map[string]AutoCodeAdapter
}

// NewAutoCodeAdapterFactory 创建适配器工厂
func NewAutoCodeAdapterFactory() *AutoCodeAdapterFactory {
	return &AutoCodeAdapterFactory{
		adapters: make(map[string]AutoCodeAdapter),
	}
}

// Register 注册适配器
func (f *AutoCodeAdapterFactory) Register(dbType string, adapter AutoCodeAdapter) {
	f.adapters[dbType] = adapter
}

// Get 获取适配器
func (f *AutoCodeAdapterFactory) Get(dbType string) AutoCodeAdapter {
	return f.adapters[dbType]
}
