fix: use repo.get(template_id, user_id) instead of repo.get_by_id
This commit is contained in:
@@ -67,7 +67,9 @@ def _calc_preview_resolution(video_ratio: str = "") -> str:
|
||||
return ratio_map.get(video_ratio.strip(), PREVIEW_RESOLUTION)
|
||||
|
||||
|
||||
def _infer_video_ratio_from_template(template_id: str, db: Session) -> str:
|
||||
def _infer_video_ratio_from_template(
|
||||
template_id: str, db: Session, user_id: str = ""
|
||||
) -> str:
|
||||
"""从模板 mode 推断视频比例,前端未传 video_ratio 时使用。
|
||||
|
||||
Returns:
|
||||
@@ -77,7 +79,7 @@ def _infer_video_ratio_from_template(template_id: str, db: Session) -> str:
|
||||
return ""
|
||||
try:
|
||||
repo = SQLAlchemyTemplateRepository(db)
|
||||
template = repo.get_by_id(template_id)
|
||||
template = repo.get(template_id, user_id)
|
||||
if template:
|
||||
mode = getattr(template, "mode", "") or ""
|
||||
ratio = _TEMPLATE_MODE_TO_RATIO.get(mode.strip(), "")
|
||||
@@ -230,7 +232,7 @@ def create_preview_generation_task(
|
||||
# 确定视频比例:优先前端传入,否则从模板 mode 推断
|
||||
video_ratio = request.video_ratio or ""
|
||||
if not video_ratio and request.template_id:
|
||||
video_ratio = _infer_video_ratio_from_template(request.template_id, db)
|
||||
video_ratio = _infer_video_ratio_from_template(request.template_id, db, user_id)
|
||||
|
||||
use_case = CreateGenerationTaskUseCase(generation_task_repository)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user