entity/README.md

36 lines
1.5 KiB
Markdown
Raw Permalink 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.

# entity 模块
实体管理模块,含实体导入。依赖 `world``scene` 模块。
## 功能
- 实体表entityCRUD实体名称/编码/所属世界/所属场景/实体类型/状态/属性 JSON
- 实体导入:上传 CSV/JSON 文件 → 解析 → 逐条校验 → 批量落库 → 写导入记录entity_import
## 数据表
| 表 | 说明 |
|----|------|
| entity | 实体表 |
| entity_import | 实体导入记录表 |
## 目录结构
```
entity/
├── entity/ # Python 包init.py 定义 load_entity 及业务函数)
├── models/ # 表定义entity.json / entity_import.json
├── json/ # CRUD 定义entity.json / entity_import.json
├── wwwroot/ # 前端index.ui / import_page.ui / api/*.dspy
├── init/data.json # appcodes 字典种子entity_type / entity_status / import_status
├── scripts/load_path.py # RBAC 权限注册
└── skill/SKILL.md # 模块技能文档
```
## 集成方式
应用入口 `app/{应用名}.py``from entity.init import load_entity`,并在 `init()` 里调用
`load_entity()`。库名由宿主应用的 `get_module_dbname('entity')` 决定,模块内不硬编码。
## 关键接口
- `load_entity()`:挂载模块函数到 ServerEnv
- `wwwroot/api/entity_import.dspy`实体导入world_id + scene_id + file
- `wwwroot/api/entity_create.dspy` / `entity_update.dspy` / `entity_delete.dspy`:实体 CRUD
- `wwwroot/api/get_search_*.dspy`:下拉数据源