- 新增 Go 语言后端服务(server/),包含用户认证、Agent管理、数据库连接等API - 新增 Python Agent 服务(agent/),实现Agent核心逻辑和工具集 - 前端从原生HTML迁移到Vue.js框架(web/src/) - 添加 Docker Compose 支持(docker-compose.yml) - 添加项目架构文档(docs/ARCHITECTURE.md) - 添加环境变量示例(.env.example)和本地启动脚本(start-local.ps1) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
84 lines
3.4 KiB
Go
84 lines
3.4 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// DatabaseInfo 数据库连接信息
|
|
type DatabaseInfo struct {
|
|
ID string `json:"id" gorm:"primaryKey;size:36"` // UUID
|
|
Name string `json:"name" gorm:"size:100;not null"` // 数据库名称
|
|
Description string `json:"description" gorm:"size:500"` // 描述
|
|
DBType string `json:"db_type" gorm:"size:20;not null"` // 数据库类型: mysql, postgres, mongodb等
|
|
Host string `json:"host" gorm:"size:255;not null"` // 主机地址
|
|
Port int `json:"port" gorm:"not null"` // 端口
|
|
Username string `json:"username" gorm:"size:100;not null"` // 用户名
|
|
Password string `json:"password" gorm:"size:255"` // 密码(建议加密存储)
|
|
Database string `json:"database" gorm:"size:100"` // 数据库名
|
|
TableCount int `json:"table_count" gorm:"default:0"` // 子表数量
|
|
|
|
// 连接选项
|
|
Charset string `json:"charset" gorm:"size:20;default:utf8mb4"` // 字符集
|
|
SSLMode string `json:"ssl_mode" gorm:"size:20"` // SSL模式
|
|
|
|
// 时间
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// TableName 表名
|
|
func (DatabaseInfo) TableName() string {
|
|
return "database_info"
|
|
}
|
|
|
|
// CreateRequest 创建数据库信息请求(支持同时保存子表配置)
|
|
type CreateDatabaseRequest struct {
|
|
Name string `json:"name" binding:"required"`
|
|
Description string `json:"description"`
|
|
DBType string `json:"db_type" binding:"required"`
|
|
Host string `json:"host" binding:"required"`
|
|
Port int `json:"port" binding:"required"`
|
|
Username string `json:"username" binding:"required"`
|
|
Password string `json:"password"`
|
|
Database string `json:"database"`
|
|
Charset string `json:"charset"`
|
|
SSLMode string `json:"ssl_mode"`
|
|
SubTables []CreateSubTableRequest `json:"sub_tables"` // 可选,子表配置
|
|
}
|
|
|
|
// UpdateRequest 更新数据库信息请求
|
|
type UpdateDatabaseRequest struct {
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
DBType string `json:"db_type"`
|
|
Host string `json:"host"`
|
|
Port int `json:"port"`
|
|
Username string `json:"username"`
|
|
Password string `json:"password"`
|
|
Database string `json:"database"`
|
|
TableCount int `json:"table_count"`
|
|
Charset string `json:"charset"`
|
|
SSLMode string `json:"ssl_mode"`
|
|
}
|
|
|
|
// CheckRequest 检查连接请求
|
|
type CheckRequest struct {
|
|
DBType string `json:"db_type" binding:"required"`
|
|
Host string `json:"host" binding:"required"`
|
|
Port int `json:"port" binding:"required"`
|
|
Username string `json:"username" binding:"required"`
|
|
Password string `json:"password"`
|
|
Database string `json:"database"`
|
|
Charset string `json:"charset"`
|
|
SSLMode string `json:"ssl_mode"`
|
|
DatabaseID string `json:"database_id"` // 可选,用于获取已保存的字段映射
|
|
}
|
|
|
|
// CheckResponse 检查连接响应
|
|
type CheckResponse struct {
|
|
Success bool `json:"success"` // 是否连接成功
|
|
Message string `json:"message"` // 消息
|
|
Tables []TableDDLInfo `json:"tables,omitempty"` // 表列表(连接成功时返回)
|
|
Database string `json:"database"` // 数据库名
|
|
}
|