312dad7497
六边形架构分层实现:
Domain 层:
- DuplicationRecord / DuplicateSegment 实体
- 状态机生命周期 (pending→processing→completed/failed)
Ports 层:
- DuplicationRecordRepository Protocol
Adapters 层:
- SQLAlchemyDuplicationRecordRepository 完整实现
- DuplicationRecordModel / DuplicationSegmentModel ORM 模型
Application 层:
- UploadForDuplicationUseCase (上传查重)
- ListDuplicationRecordsUseCase (记录列表)
- GetDuplicationDetailUseCase (详情查询)
- DeleteDuplicationRecordUseCase (删除)
- RetryDuplicationUseCase (重新查重)
API 层:
- POST /api/v1/duplication/upload (上传视频查重)
- GET /api/v1/duplication/records (记录列表)
- GET /api/v1/duplication/records/{id} (详情含片段)
- DELETE /api/v1/duplication/records/{id} (删除)
- POST /api/v1/duplication/records/{id}/retry (重新查重)
Alembic 迁移:
- 011_add_duplication_tables.py (duplication_records + duplication_segments)
API 契约与前端 feat/phase2-duplication-ui (PR#75) 完全对齐。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
46 lines
1000 B
Python
46 lines
1000 B
Python
"""查重 API Pydantic schemas。"""
|
|
from __future__ import annotations
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class DuplicateSegmentResponse(BaseModel):
|
|
"""重复片段响应。"""
|
|
|
|
id: str
|
|
source_start: float
|
|
source_end: float
|
|
matched_video_id: str
|
|
matched_video_name: str
|
|
matched_start: float
|
|
matched_end: float
|
|
similarity: float
|
|
|
|
|
|
class DuplicationRecordResponse(BaseModel):
|
|
"""查重记录响应(列表项)。"""
|
|
|
|
id: str
|
|
filename: str
|
|
file_size: int
|
|
duration_seconds: float = 0.0
|
|
status: str = "pending"
|
|
duplicate_rate: float | None = None
|
|
duplicate_count: int = 0
|
|
created_at: str
|
|
updated_at: str
|
|
|
|
|
|
class DuplicationDetailResponse(DuplicationRecordResponse):
|
|
"""查重详情响应(含重复片段)。"""
|
|
|
|
segments: list[DuplicateSegmentResponse] = Field(default_factory=list)
|
|
|
|
|
|
class DuplicationUploadResponse(BaseModel):
|
|
"""上传查重响应。"""
|
|
|
|
id: str
|
|
status: str
|
|
message: str
|