feat(#1197): Phase 1 预览生成接口(单版本预览)
实现预览生成功能的后端 Phase 1:单版本预览接口(创建 + 查询)。 变更内容: - 领域模型 GenerationTask 新增 is_preview: bool = False 字段 - SQLAlchemy GenerationTaskModel 新增 is_preview 列(带索引) - 新增 alembic migration 053_generation_task_is_preview - 仓储层 _to_domain/create/update 同步 is_preview 字段(getattr 兼容旧数据) - CreateGenerationTaskCommand/UseCase 新增 is_preview 参数 - Schema 新增 CreatePreviewGenerationTaskRequest 和 PreviewGenerationTaskResponse - 新增 /api/v1/generation/preview 路由(POST 创建 + GET 查询) - Worker generate_video 检测 is_preview=True 时强制 854x480 + 1M 低码率 - 新增 29 个单元测试,全部通过 验收: - ✅ 所有新增文件写完,所有修改点完成 - ✅ 单元测试 29 个,全部通过 - ✅ 现有 generation 相关 174 个测试全部通过 - ✅ 代码通过 ruff + black 检查 - ✅ 在 feat/preview-generation-1197 分支上
This commit is contained in:
@@ -36,6 +36,7 @@ def _to_domain(model: GenerationTaskModel) -> GenerationTask:
|
||||
video_title=getattr(model, "video_title", "") or "",
|
||||
resolution=getattr(model, "resolution", "") or "",
|
||||
bgm_config=dict(getattr(model, "bgm_config", {}) or {}),
|
||||
is_preview=bool(getattr(model, "is_preview", False)),
|
||||
logs=model.logs or "[]",
|
||||
created_at=model.created_at,
|
||||
updated_at=model.updated_at,
|
||||
@@ -74,6 +75,7 @@ class SQLAlchemyGenerationTaskRepository:
|
||||
video_title=task.video_title or "",
|
||||
resolution=task.resolution or "",
|
||||
bgm_config=task.bgm_config or {},
|
||||
is_preview=task.is_preview or False,
|
||||
logs=task.logs,
|
||||
created_at=task.created_at,
|
||||
updated_at=task.updated_at,
|
||||
@@ -238,6 +240,8 @@ class SQLAlchemyGenerationTaskRepository:
|
||||
model.resolution = task.resolution or ""
|
||||
if hasattr(model, "bgm_config"):
|
||||
model.bgm_config = task.bgm_config or {}
|
||||
if hasattr(model, "is_preview"):
|
||||
model.is_preview = task.is_preview or False
|
||||
model.logs = task.logs
|
||||
self.session.commit()
|
||||
return task
|
||||
|
||||
@@ -292,6 +292,7 @@ class GenerationTaskModel(Base):
|
||||
batch_id = Column(String(36), nullable=False, default="", index=True)
|
||||
video_title = Column(String(255), nullable=False, default="")
|
||||
resolution = Column(String(20), nullable=False, default="")
|
||||
is_preview = Column(Boolean, nullable=False, default=False, index=True)
|
||||
bgm_config = Column(JSON, nullable=False, default=dict)
|
||||
extra_meta = Column("metadata", JSON, nullable=False, default=dict)
|
||||
logs = Column(Text, nullable=False, default="[]", server_default="[]")
|
||||
|
||||
Reference in New Issue
Block a user