feat(phase1): 完成文档上传接口

Task 5.3: 文档上传接口
- 创建 DocumentManagementService:文档上传核心逻辑
  - 文件格式验证(仅 .md/.txt)
  - 文件 hash 计算与去重检查
  - 文本提取与分块处理
  - 文档元数据持久化(ApiDocument)
  - 向量化索引标记为 TODO(待补充)
- 创建 DocumentController:RESTful 上传接口
  - POST /api/documents/upload
  - 支持参数:file, faultCategory, faultSource, apiName, version
  - 返回:文档 docId

功能特性:
- MD5 hash 去重:防止重复上传
- 事务支持:元数据与索引状态一致性
- 异常处理:DocumentProcessException 统一封装
- 分块配置:使用 DocumentChunkConfig 默认配置

待补充:
- TODO: VectorIndexService.indexDocumentChunks() 实现
- 当前文档状态直接标记为 INDEXED

编译验证:BUILD SUCCESS

Progress: 26/33 tasks completed (79%)
This commit is contained in:
zhuyongxin
2026-06-23 15:28:02 +08:00
parent 5869fc775f
commit f446290d0f
3 changed files with 218 additions and 1 deletions
@@ -39,7 +39,7 @@
- [x] 5.1 创建 TextExtractor 服务 (仅支持 .md 和 .txt,其他格式通过外部转换服务)
- [x] 5.2 文档分块服务 (DocumentChunkService 已存在,已适配新 DTO)
- [ ] 5.3 文档上传接口 (DocumentController#upload, DocumentService#uploadDocument)
- [x] 5.3 文档上传接口 (DocumentController#upload, DocumentManagementService#uploadDocument)
- [ ] 5.4 文档查询接口 (DocumentController#query, DocumentService#queryDocuments)
- [ ] 5.5 文档删除接口 (DocumentController#delete, DocumentService#deleteDocument)
- [ ] 5.6 混合检索工具 (DocumentSearchTool: 精确匹配 + 语义检索 + RRF 融合)