chore: 添加数据库资源和需求文档
- 新增数据库连接配置 (db_info) - 添加 DDL 编辑需求文档 - 添加 TODO 待办事项 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"database_id": "44cf2f22-fccb-4dd0-92fb-02d613ce2624",
|
||||
"database_name": "1231",
|
||||
"db_type": "mysql",
|
||||
"tables": [
|
||||
{
|
||||
"id": "042fb35c-9023-40ed-8d3a-cec24f0709a2",
|
||||
"database_id": "44cf2f22-fccb-4dd0-92fb-02d613ce2624",
|
||||
"parent_table": "scores",
|
||||
"sub_table_name": "scores",
|
||||
"sub_table_comment": "",
|
||||
"mapping_type": "",
|
||||
"relation_field": "",
|
||||
"relation_type": "",
|
||||
"fields": null,
|
||||
"ddl": "CREATE TABLE `scores` (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `student_id` int(10) unsigned NOT NULL,\n `subject` varchar(50) NOT NULL COMMENT '科目',\n `score` double DEFAULT NULL COMMENT '分数',\n `teacher_id` int(10) unsigned DEFAULT NULL,\n `exam_date` date DEFAULT NULL COMMENT '考试日期',\n `created_at` datetime DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=utf8mb4",
|
||||
"created_at": "2026-03-07T09:59:48.436+08:00",
|
||||
"updated_at": "2026-03-07T09:59:48.436+08:00"
|
||||
}
|
||||
],
|
||||
"updated_at": "2026-03-07T09:59:48.4882963+08:00"
|
||||
}
|
||||
66
team-require/web/ddl-edit.md
Normal file
66
team-require/web/ddl-edit.md
Normal file
@@ -0,0 +1,66 @@
|
||||
# 后端需求 - DDL 编辑功能
|
||||
|
||||
## 问题描述
|
||||
|
||||
前端 Database 页面的 Table Mapping 功能已从"字段映射"改为"DDL 编辑"模式。后端需要支持保存和读取 DDL 数据。
|
||||
|
||||
## 需求
|
||||
|
||||
### 1. 保存 DDL
|
||||
|
||||
前端保存时发送 `ddl` 字段而非 `fields` 字段。
|
||||
|
||||
请求结构:
|
||||
```json
|
||||
{
|
||||
"name": "数据库名",
|
||||
"sub_tables": [
|
||||
{
|
||||
"parent_table": "users",
|
||||
"sub_table_name": "用户表",
|
||||
"sub_table_comment": "用户表",
|
||||
"ddl": "CREATE TABLE users (...)"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 2. 后端处理
|
||||
|
||||
- `CreateSubTableRequest` 已有 `DDL string` 字段(已添加)
|
||||
- `UpdateSubTableRequest` 已有 `DDL string` 字段(已添加)
|
||||
- `UpdateDatabaseRequest` 已有 `SubTables []CreateSubTableRequest` 字段(已添加)
|
||||
|
||||
### 3. Service 层修改
|
||||
|
||||
**sub_table_service.go**:
|
||||
|
||||
1. `Create` 函数 - 添加 DDL 字段赋值:
|
||||
```go
|
||||
info := &model.SubTableInfo{
|
||||
// ... 现有字段
|
||||
DDL: req.DDL,
|
||||
}
|
||||
```
|
||||
|
||||
2. `Update` 函数 - 添加 DDL 更新逻辑:
|
||||
```go
|
||||
// 更新 DDL
|
||||
info.DDL = req.DDL
|
||||
```
|
||||
|
||||
**database_service.go 或 handler**:
|
||||
|
||||
在 `Update` 方法中处理 `SubTables` 字段:
|
||||
- 当前端传入 `sub_tables` 时,需要创建或更新对应的子表记录(包括 DDL)
|
||||
- 遍历 `sub_tables`,调用 `SubTableService.Create` 或 `SubTableService.Update`
|
||||
|
||||
## 影响范围
|
||||
|
||||
- `server/internal/service/sub_table_service.go` - Create/Update 方法
|
||||
- `server/internal/service/database_service.go` 或 handler - Update 方法处理 SubTables
|
||||
|
||||
## 状态
|
||||
|
||||
- [x] 前端修改完成
|
||||
- [x] 后端修改已完成
|
||||
13
team-require/web/todo-2026-3-7.md
Normal file
13
team-require/web/todo-2026-3-7.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# Web 前端需求 TODO
|
||||
|
||||
## 2026年3月
|
||||
|
||||
### 2026-03-07
|
||||
|
||||
- [x] **DDL 编辑功能** - 后端已完成 ✔
|
||||
- 前端只发送 ddl 字段,不再发送 fields 字段
|
||||
- 详细需求:[ddl-edit.md](./ddl-edit.md)
|
||||
|
||||
---
|
||||
|
||||
> 需求完成后请完成者打 ✔
|
||||
Reference in New Issue
Block a user