Files
X-Agents/team-require/web/columns-api.md
DESKTOP-72TV0V4\caoxiaozhu b2bc9988a9 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>
2026-03-06 16:39:42 +08:00

93 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 后端需求 - 表结构返回 columns 数据
## 问题描述
前端在 Edit Mapping 页面需要展示表的列信息字段名、类型、COMMENT等但前端自行解析 DDL 存在困难。
## 需求
后端在获取表结构列表时,需要同时返回:
1. **DDL 语句**(已有的需求,继续保留)
2. **结构化的 columns 数据**(新增)
### 返回数据结构
```json
{
"success": true,
"tables": [
{
"table_name": "exam_scores",
"table_comment": "考试成绩表",
"ddl": "CREATE TABLE `exam_scores` (...)",
"columns": [
{
"column_name": "id",
"data_type": "int",
"column_type": "int(10) unsigned",
"is_nullable": "NO",
"default_value": null,
"column_key": "PRI",
"extra": "auto_increment",
"column_comment": ""
},
{
"column_name": "student_id",
"data_type": "int",
"column_type": "int(10) unsigned",
"is_nullable": "NO",
"default_value": null,
"column_key": "",
"extra": "",
"column_comment": ""
},
{
"column_name": "subject",
"data_type": "varchar",
"column_type": "varchar(50)",
"is_nullable": "NO",
"default_value": null,
"column_key": "",
"extra": "",
"column_comment": "科目"
},
{
"column_name": "score",
"data_type": "double",
"column_type": "double",
"is_nullable": "YES",
"default_value": null,
"column_key": "",
"extra": "",
"column_comment": "分数"
}
]
}
]
}
```
### 字段说明
| 字段 | 类型 | 说明 |
|------|------|------|
| column_name | string | 列名 |
| data_type | string | 数据类型(如 int, varchar, double |
| column_type | string | 完整列类型(如 int(10) unsigned |
| is_nullable | string | 是否可空YES/NO |
| default_value | string | 默认值 |
| column_key | string | 主键标识PRI/MUL/UNI |
| extra | string | 额外信息(如 auto_increment |
| column_comment | string | 列注释 |
## 影响范围
- 文件:`server/internal/service/database_service.go`
- 函数:`getMySQLTables`, `getPostgresTables`
- 数据模型:`server/internal/model/sub_table_info.go``ColumnInfo` 结构体
## 优先级
高 - 前端 Edit Mapping 页面字段映射功能依赖此数据