76 lines
1.4 KiB
Markdown
76 lines
1.4 KiB
Markdown
# 导出记录生成Skill 设计
|
|
|
|
## 1. Skill 定位
|
|
|
|
`导出记录生成Skill` 负责保存导出文件元数据、生成下载入口、构建导出报告并写入审计。
|
|
|
|
英文实现标识建议使用 `ExportRecordBuildSkill`。
|
|
|
|
## 2. 输入
|
|
|
|
```python
|
|
@dataclass
|
|
class ExportRecordBuildInput:
|
|
batch_id: int
|
|
output_file_path: Path | None
|
|
export_mode: str
|
|
layout_check_result: dict
|
|
filled_fields: list[dict]
|
|
blocked_fields: list[dict]
|
|
```
|
|
|
|
## 3. 输出
|
|
|
|
```python
|
|
@dataclass
|
|
class ExportRecordBuildOutput:
|
|
report: dict
|
|
output_file: dict | None
|
|
audit_payload: dict
|
|
```
|
|
|
|
## 4. 核心方法
|
|
|
|
### 4.1 `run(input) -> ExportRecordBuildOutput`
|
|
|
|
主入口方法。
|
|
|
|
### 4.2 `create_export_file_record(file_path) -> ExportedDocument`
|
|
|
|
创建导出文件记录。
|
|
|
|
### 4.3 `build_download_url(export_file) -> str`
|
|
|
|
生成下载 URL。
|
|
|
|
### 4.4 `build_report(input, output_file) -> dict`
|
|
|
|
生成导出报告。
|
|
|
|
### 4.5 `build_audit_payload(report) -> dict`
|
|
|
|
生成审计载荷。
|
|
|
|
## 5. 技术实现
|
|
|
|
使用技术:
|
|
|
|
1. Django ORM
|
|
2. Django Storage
|
|
3. JSONField
|
|
4. Audit 服务
|
|
|
|
## 6. 异常处理
|
|
|
|
1. 文件不存在:只生成拦截报告。
|
|
2. 下载链接生成失败:报告标记异常。
|
|
3. 审计失败:记录系统警告。
|
|
|
|
## 7. 测试要点
|
|
|
|
1. 文件记录创建成功。
|
|
2. 下载链接生成成功。
|
|
3. 拦截模式不创建文件。
|
|
4. 审计载荷完整。
|
|
|