world/README.md

46 lines
2.4 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 世界管理模块
世界定义与管理模块W-01 世界管理),平台入口域根模块。
## 功能
- world 表 CRUD创建自动编码 W+时间戳+随机4位
- 列表查询sqlPaging 分页 + 复合索引org_id+mode+created_at过滤返回 {list, total}
- world.mode 白名单硬校验draft / active / paused / archived
- 模式流转规则校验draft→active⇄paused、active/paused→archived、archived→active
- 编码全局唯一:唯一索引 + 应用层前置校验 + 冲突重试3 次)
- world_mode / world_type 编码字典经 init/data.json 幂等落库appcodes + appcodes_kv
## 数据表
- `world`世界定义表models/world.json四段式 summary/fields/indexes/codes
- 编码字典:`world_mode`draft/active/paused/archived`world_type`game/simulation/education/business/social
## 接口
REST 统一前缀 `/api/*`,错误结构 `{code, message, field, detail}`,分页 `{list, total}`
- `POST/GET /world/api/create_world.dspy` 创建自动编码、mode 校验)
- `POST /world/api/world_update.dspy` 更新mode 流转校验、code 唯一校验)
- `POST /world/api/world_delete.dspy` 删除
- `GET /world/api/get_world.dspy` 单条查询
- `GET /world/api/list_worlds.dspy` 列表(分页 + 过滤)
- `POST /world/api/set_world_mode.dspy` 模式切换
- `GET /world/api/get_search_status.dspy` / `get_search_world_type.dspy` 下拉数据源
## 安装与集成
1. `pip install .`pyproject.toml依赖 sqlor / bricks_for_python
2. 宿主应用 `from world.init import load_world`init() 中 `load_world()` 挂载
3. 建表build.sh 中 json2ddl 依据 models/world.json 生成 DDL编码字典经 init/data.json 幂等落库
4. RBAC运行 `scripts/load_path.py`(显式路径注册,禁通配符)
5. 前端wwwroot/index.ui入口、menu.ui菜单、CRUD 由 json/world.json 经 xls2ui 生成
## 目录结构
```
world/
├── world/ # Python 包world.py 业务逻辑 / init.py 注册 / __init__.py 导出)
├── wwwroot/ # index.ui、menu.ui、api/*.dspy
├── models/world.json # 表定义(四段式)
├── json/world.json # CRUD 定义tblname+params
├── init/data.json # 编码字典种子数据
├── scripts/load_path.py # RBAC 注册
├── skill/SKILL.md # 模块技能文档
└── pyproject.toml # 打包
```