feat: 重构前后端架构,添加Go后端和Python Agent服务
- 新增 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>
This commit is contained in:
103
team-require/api/database-check.md
Normal file
103
team-require/api/database-check.md
Normal file
@@ -0,0 +1,103 @@
|
||||
# 检查数据库连接并获取表结构
|
||||
|
||||
## 接口地址
|
||||
|
||||
```
|
||||
POST /database/check
|
||||
```
|
||||
|
||||
## 请求参数
|
||||
|
||||
| 参数 | 类型 | 必填 | 说明 |
|
||||
|------|------|------|------|
|
||||
| db_type | string | 是 | 数据库类型:`mysql`、`postgres` |
|
||||
| host | string | 是 | 数据库主机 |
|
||||
| port | int | 是 | 数据库端口 |
|
||||
| username | string | 是 | 用户名 |
|
||||
| password | string | 否 | 密码 |
|
||||
| database | string | 是 | 数据库名 |
|
||||
| charset | string | 否 | 字符集,默认 `utf8mb4` |
|
||||
| ssl_mode | string | 否 | SSL 模式 |
|
||||
| database_id | string | 否 | 已存在的数据库ID,用于恢复字段映射 |
|
||||
|
||||
## 请求示例
|
||||
|
||||
```json
|
||||
{
|
||||
"db_type": "mysql",
|
||||
"host": "localhost",
|
||||
"port": 3306,
|
||||
"username": "root",
|
||||
"password": "root",
|
||||
"database": "students",
|
||||
"charset": "utf8mb4",
|
||||
"database_id": "xxx-xxx-xxx" // 可选,用于恢复字段映射
|
||||
}
|
||||
```
|
||||
|
||||
## 返回参数
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| success | bool | 是否连接成功 |
|
||||
| message | string | 消息 |
|
||||
| database | string | 数据库名 |
|
||||
| tables | array | 表结构列表 |
|
||||
|
||||
### tables[] 详情
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| table_name | string | 表名 |
|
||||
| table_comment | string | 表注释 |
|
||||
| ddl | string | 建表 DDL(带 COMMENT 的映射后 DDL) |
|
||||
| columns | array | 列信息列表 |
|
||||
|
||||
### columns[] 详情
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| column_name | string | 列名 |
|
||||
| data_type | string | 数据类型 |
|
||||
| column_type | string | 完整列类型 |
|
||||
| is_nullable | string | 是否可空(YES/NO) |
|
||||
| default_value | string | 默认值 |
|
||||
| column_key | string | 主键标识(PRI/MUL/UNI) |
|
||||
| extra | string | 额外信息(如 auto_increment) |
|
||||
| column_comment | string | 列注释 |
|
||||
| mapped_name | string | 字段中文映射名(已保存的映射) |
|
||||
|
||||
## 返回示例
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "connection successful",
|
||||
"database": "students",
|
||||
"tables": [
|
||||
{
|
||||
"table_name": "users",
|
||||
"table_comment": "用户表",
|
||||
"ddl": "CREATE TABLE `users` (\n `id` int(10) unsigned NOT NULL COMMENT '用户ID'\n ...\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4",
|
||||
"columns": [
|
||||
{
|
||||
"column_name": "id",
|
||||
"data_type": "int",
|
||||
"column_type": "int(10) unsigned",
|
||||
"is_nullable": "NO",
|
||||
"default_value": "",
|
||||
"column_key": "PRI",
|
||||
"extra": "auto_increment",
|
||||
"column_comment": "",
|
||||
"mapped_name": "用户ID"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 使用场景
|
||||
|
||||
1. **首次连接**:不传 `database_id`,获取实时表结构
|
||||
2. **恢复映射**:传入 `database_id`,返回已保存的 `mapped_name` 和 `ddl`
|
||||
Reference in New Issue
Block a user