Files
xiaoxia-saas/apps/api/app/schemas/generation_task.py
T
灵应 356df4663e
Deploy / Staging E2E Tests (push) Has been cancelled
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
Deploy / Deploy Staging (push) Failing after 111h7m48s
CI/CD Pipeline / Frontend Lint (push) Failing after 111h7m57s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 111h7m57s
fix: 修复素材库诊断/缩略图/视频URL + 剪辑计划错误处理
Task #105: 修复剪辑计划/模板页面报服务器繁忙
- templates.py: list_templates/get_template/list_categories 加 try/except
- templates.py: 新增 POST /{template_id}/toggle-favorite 兼容端点
- edit_plans.py: list_plans 加 try/except,ai_tasks 加 ImportError 守卫

Task #106: 修复素材库诊断按钮 + 缩略图/视频URL
- asset_diagnosis.py: get_project_asset_diagnosis 加 try/except
- assets.py: 注入 storage_service,生成签名 file_url
- asset.py schema: 新增 file_url 字段
- 视频素材 thumbnail_url 为空时复用 file_url 作为封面

其他:
- edit_plans/generation_tasks 支持 source_edit_plan_id
- Alembic 迁移 022: 两表加 source_edit_plan_id 字段
2026-07-04 21:46:32 +08:00

59 lines
2.0 KiB
Python

from pydantic import BaseModel, Field, model_validator
class CreateGenerationTaskRequest(BaseModel):
"""创建生成任务请求。
支持两种模式(至少提供一种):
- 项目模式:project_id + asset_library_id(向后兼容)
- 模板模式:template_id + asset_ids / title_ids / voice_ids
"""
project_id: str = ""
asset_library_id: str = ""
strategy_id: str = ""
voice_library_id: str = ""
created_by_user_id: str = ""
# ── 模板模式新增字段 ──
template_id: str = ""
asset_ids: list[str] = Field(default_factory=list)
title_ids: list[str] = Field(default_factory=list)
voice_ids: list[str] = Field(default_factory=list)
# ── 来源剪辑计划 ──
source_edit_plan_id: str = ""
@model_validator(mode="after")
def _check_at_least_one_mode(self) -> "CreateGenerationTaskRequest":
has_project = bool(self.project_id.strip())
has_template = bool(self.template_id.strip())
if not has_project and not has_template:
raise ValueError("project_id 或 template_id 至少需要提供一个")
has_library = bool(self.asset_library_id.strip())
has_assets = bool(self.asset_ids or self.title_ids or self.voice_ids)
if not has_library and not has_assets:
raise ValueError("asset_library_id 或 asset_ids/title_ids/voice_ids 至少需要提供一个")
return self
class GenerationTaskResponse(BaseModel):
id: str
project_id: str
asset_library_id: str
strategy_id: str
voice_library_id: str
template_id: str = ""
asset_ids: list[str] = Field(default_factory=list)
title_ids: list[str] = Field(default_factory=list)
voice_ids: list[str] = Field(default_factory=list)
source_edit_plan_id: str = ""
status: str
progress: float
result_count: int
error_message: str
class ListGenerationTasksResponse(BaseModel):
"""用户级生成任务列表响应(跨 project)。"""
items: list[GenerationTaskResponse]