fix: 修复复审2个建议 (models注释 + N+1查询 + 事务边界)
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Lint (pull_request) Has been cancelled

- models.py: 注释中旧模式名对齐 EditingMode 枚举
- list_by_user: 批量加载 segments 避免 N+1 查询
- create(): flush 替代 commit,create_segments 统一提交事务
This commit is contained in:
Audit Bot
2026-06-29 14:53:21 +08:00
parent 9b6a0b8b14
commit 78524a04eb
3 changed files with 35 additions and 19 deletions
+2 -2
View File
@@ -287,7 +287,7 @@ class TemplateModel(Base):
id = Column(String(36), primary_key=True)
user_id = Column(String(36), nullable=False, index=True)
name = Column(String(200), nullable=False)
mode = Column(String(30), nullable=False, index=True) # pip / person_narration / one_take / voice_over_mix
mode = Column(String(30), nullable=False, index=True) # EditingMode 枚举值: pip / voice_pip / one_take / voice_over
category = Column(String(100), nullable=False, default="")
tags = Column(JSON, nullable=False, default=list)
title_config = Column(JSON, nullable=False, default=dict)
@@ -307,7 +307,7 @@ class TemplateSegmentModel(Base):
segment_order = Column(Integer, nullable=False)
duration_min = Column(Float, nullable=False)
duration_max = Column(Float, nullable=False)
material_type = Column(String(20), nullable=True) # 仅 voice_over_mix: 人物/场景
material_type = Column(String(20), nullable=True) # 仅 voice_over 模式: 人物/场景
created_at = Column(DateTime, nullable=False, default=lambda: datetime.now(timezone.utc))
updated_at = Column(DateTime, nullable=False, default=lambda: datetime.now(timezone.utc))