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:
89
team-require/web/field-mapping.md
Normal file
89
team-require/web/field-mapping.md
Normal file
@@ -0,0 +1,89 @@
|
||||
# 后端需求 - 字段映射保存与读取
|
||||
|
||||
## 问题描述
|
||||
|
||||
前端 Edit Mapping 页面中,用户输入的字段中文映射名(mapped_name)在保存后,第二次打开时丢失了。
|
||||
|
||||
## 原因分析
|
||||
|
||||
1. **保存时**:前端只保存了表级别信息,没有保存字段的中文映射
|
||||
2. **加载时**:前端每次都从 `/database/check` 重新获取表结构,没有读取已保存的映射数据
|
||||
|
||||
## 需求
|
||||
|
||||
### 1. 保存字段映射
|
||||
|
||||
前端保存时需要传递每个字段的中文映射名,后端需要存储这些数据。
|
||||
|
||||
请求结构:
|
||||
```json
|
||||
{
|
||||
"name": "数据库名",
|
||||
"sub_tables": [
|
||||
{
|
||||
"parent_table": "users",
|
||||
"sub_table_name": "用户表",
|
||||
"sub_table_comment": "用户表",
|
||||
"fields": [
|
||||
{
|
||||
"column_name": "id",
|
||||
"mapped_name": "编号"
|
||||
},
|
||||
{
|
||||
"column_name": "username",
|
||||
"mapped_name": "用户名"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 2. 返回字段映射
|
||||
|
||||
后端在返回表结构时,需要同时返回已保存的字段映射信息。
|
||||
|
||||
返回结构:
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"tables": [
|
||||
{
|
||||
"table_name": "users",
|
||||
"table_comment": "用户表",
|
||||
"ddl": "...",
|
||||
"columns": [
|
||||
{
|
||||
"column_name": "id",
|
||||
"data_type": "int",
|
||||
"column_type": "int(10)",
|
||||
"column_comment": "",
|
||||
"mapped_name": "编号"
|
||||
},
|
||||
{
|
||||
"column_name": "username",
|
||||
"data_type": "varchar",
|
||||
"column_type": "varchar(50)",
|
||||
"column_comment": "用户名",
|
||||
"mapped_name": "用户名"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 3. 数据存储
|
||||
|
||||
- 可以在 `sub_table_info` 表中增加 `fields` JSON 字段存储字段映射
|
||||
- 或者创建新的关联表 `sub_table_fields`
|
||||
|
||||
## 影响范围
|
||||
|
||||
- `server/internal/service/database_service.go` - Create/Update 方法
|
||||
- `server/internal/model/` - 数据模型修改
|
||||
- 子表映射的数据存储结构
|
||||
|
||||
## 优先级
|
||||
|
||||
高 - 用户输入的映射数据丢失影响使用体验
|
||||
Reference in New Issue
Block a user