feat: parse docx blocks during upload

This commit is contained in:
zwt13703
2026-07-01 20:29:31 +08:00
parent 95c507536a
commit 389b9c0c92
5 changed files with 147 additions and 54 deletions
+12
View File
@@ -23,3 +23,15 @@
4. 复用并完善文件校验、MinIO/本地降级存储与 template 表插入逻辑。
5. 执行 Python 语法检查与 FastAPI 路由导入检查,确认 `/api/templates/upload` 已注册。
- **执行结果**: 完成模板上传接口基础链路,任务 015-018 已在任务清单中标注为已完成。
## 会话 ID: 20260701-doc-parser
- [2026-07-01 20:29:17]
- **执行原因**: 按任务清单继续完成 Word 解析阶段 019-025。
- **执行过程**:
1. 重写 Word block 遍历逻辑,按文档 XML 原始顺序同时遍历段落和表格。
2. 实现 Heading 1-6/标题 1-6 识别、普通段落识别、表格行列数和表头预览提取。
3. 为解析结果顺序生成 `block_001` 形式的 `block_id``sort_order`
4. 基于标题层级计算 `parent_block_id`,并输出树结构节点。
5. 新增 `save_template_blocks`,上传模板后批量写入 `template_block`
6. 使用临时 docx 验证标题、段落、表格混排时的顺序和父子关系。
- **执行结果**: 完成任务 019-025,上传模板时会解析 Word 并保存模板区域块。