mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-12 07:29:40 +08:00
- 集成 go-ora, dm, gokb 驱动,封装统一的 Database 接口实现,支持自定义 DSN 连接 - 新增 SyncEngine 同步引擎,支持基于主键的增量数据比对 (Insert/Update) - 新增 DataSyncModal 组件,实现三步走同步向导逻辑,修复 Transfer 组件空状态显示问题 - 优化 ConnectionModal 交互逻辑,支持驱动参数动态显隐 - 引入 antd/locale/zh_CN,统一应用界面的中文本地化显示
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package db
|
|
|
|
import (
|
|
"GoNavi-Wails/internal/connection"
|
|
"fmt"
|
|
)
|
|
|
|
type Database interface {
|
|
Connect(config connection.ConnectionConfig) error
|
|
Close() error
|
|
Ping() error
|
|
Query(query string) ([]map[string]interface{}, []string, error)
|
|
Exec(query string) (int64, error)
|
|
GetDatabases() ([]string, error)
|
|
GetTables(dbName string) ([]string, error)
|
|
GetCreateStatement(dbName, tableName string) (string, error)
|
|
GetColumns(dbName, tableName string) ([]connection.ColumnDefinition, error)
|
|
GetAllColumns(dbName string) ([]connection.ColumnDefinitionWithTable, error)
|
|
GetIndexes(dbName, tableName string) ([]connection.IndexDefinition, error)
|
|
GetForeignKeys(dbName, tableName string) ([]connection.ForeignKeyDefinition, error)
|
|
GetTriggers(dbName, tableName string) ([]connection.TriggerDefinition, error)
|
|
}
|
|
|
|
type BatchApplier interface {
|
|
ApplyChanges(tableName string, changes connection.ChangeSet) error
|
|
}
|
|
|
|
// Factory
|
|
func NewDatabase(dbType string) (Database, error) {
|
|
switch dbType {
|
|
case "mysql":
|
|
return &MySQLDB{}, nil
|
|
case "postgres":
|
|
return &PostgresDB{}, nil
|
|
case "sqlite":
|
|
return &SQLiteDB{}, nil
|
|
case "oracle":
|
|
return &OracleDB{}, nil
|
|
case "dameng":
|
|
return &DamengDB{}, nil
|
|
case "kingbase":
|
|
return &KingbaseDB{}, nil
|
|
case "custom":
|
|
return &CustomDB{}, nil
|
|
default:
|
|
// Default to MySQL for backward compatibility if empty
|
|
if dbType == "" {
|
|
return &MySQLDB{}, nil
|
|
}
|
|
return nil, fmt.Errorf("unsupported database type: %s", dbType)
|
|
}
|
|
}
|