world_sync/README.md

50 lines
2.2 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.

# world_sync 同步管理模块W-05
元景项目 W-05 同步管理功能模块,负责同步配置、同步任务执行与同步日志查询。
## 功能
- **同步配置管理**`world_sync` 表 CRUD同步编码唯一、类型/模式/状态白名单校验,非法输入 100% 拦截不落库)
- **同步任务执行**`create_sync_task` 创建任务 + `execute_sync_task` 批量事务执行,任一条失败整体回滚,无脏数据
- **同步日志查询**`world_sync_log` 分页查询({list,total}
- **编码字典**`sync_status` / `sync_type``init/data.json` 幂等落库到 appcodes/appcodes_kv
## 数据表models/
| 表 | 说明 |
|---|---|
| world_sync | 同步配置sync_code 唯一) |
| world_sync_task | 同步任务batch_no 批次、统计计数、状态) |
| world_sync_log | 同步日志task_id 关联、payload/result/error_msg |
## 安装与集成
```bash
pip install .
```
宿主应用接入(三处):
1. `app/{app}.py`:定义 `get_module_dbname('world_sync')` 并挂 ServerEnv`init()``from world_sync.init import load_world_sync; load_world_sync()`
2. `spec.json``generated_modules` 加入 `"world_sync"`
3. RBAC运行 `scripts/load_path.py`(或在中央 load_path.py 显式登记 `/world_sync/*` 路径,禁止通配符)
## REST 接口(统一前缀 /api/*
| 路径 | 说明 |
|---|---|
| POST /world_sync/api/world_sync_create.dspy | 新增同步配置 |
| POST /world_sync/api/world_sync_update.dspy | 更新同步配置 |
| POST /world_sync/api/world_sync_delete.dspy | 删除同步配置 |
| GET /world_sync/api/world_sync_list.dspy | 配置分页列表 |
| POST /world_sync/api/world_sync_task_create.dspy | 创建同步任务 |
| POST /world_sync/api/world_sync_task_execute.dspy | 执行同步任务batch 事务) |
| GET /world_sync/api/world_sync_task_list.dspy | 任务分页列表 |
| GET /world_sync/api/world_sync_log_list.dspy | 日志分页查询 |
| GET /world_sync/api/world_sync_dict.dspy | 编码字典 |
错误结构:`{code, message, field, detail}`;分页结构:`{list, total}`
## 技术栈
Python 3.8+ / sqlor / ahserver ServerEnv / bricks-framework前端 .ui