Files
X-Agents/teams/api/subtable-list.md
2026-03-11 14:26:47 +08:00

76 lines
1.8 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.
# 获取子表列表
## 接口地址
```
GET /sub-table/database/:database_id
```
## 路径参数
| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| database_id | string | 是 | 数据库ID |
## 返回参数
| 参数 | 类型 | 说明 |
|------|------|------|
| list | array | 子表列表 |
### list[] 详情
| 参数 | 类型 | 说明 |
|------|------|------|
| id | string | 子表ID |
| database_id | string | 关联的数据库ID |
| parent_table | string | 原始表名 |
| sub_table_name | string | 子表别名 |
| sub_table_comment | string | 子表注释 |
| mapping_type | string | 映射类型 |
| relation_field | string | 关联字段 |
| relation_type | string | 关联类型 |
| fields | array | 字段映射列表 |
| ddl | string | 建表 DDL带 COMMENT |
| created_at | string | 创建时间 |
### fields[] 详情
| 参数 | 类型 | 说明 |
|------|------|------|
| column_name | string | 列名 |
| mapped_name | string | 中文映射名 |
## 返回示例
```json
{
"list": [
{
"id": "xxx-xxx",
"database_id": "database-xxx",
"parent_table": "users",
"sub_table_name": "用户表",
"sub_table_comment": "用户信息",
"mapping_type": "horizontal",
"relation_field": "id",
"relation_type": "one_to_many",
"fields": [
{"column_name": "id", "mapped_name": "用户ID"},
{"column_name": "name", "mapped_name": "用户名"}
],
"ddl": "CREATE TABLE `users` (\n `id` int(10) unsigned NOT NULL COMMENT '用户ID'\n ...\n)",
"created_at": "2026-03-06T15:00:00Z"
}
]
}
```
## 使用场景
用于恢复映射状态:
1. 用户点击已存在的数据库的 "Map Tables" 按钮
2. 调用此接口获取已保存的子表信息
3. 根据 `parent_table` 勾选已选择的表
4. 根据 `fields` 恢复字段映射