feat(phase8-task202): TemplateClipConfig + EditPlanClip 数据模型 #143

Closed
xiaoxia wants to merge 1 commits from feature/phase8-task202-clip-models into develop
Owner

Phase 8 任务 2.02: TemplateClipConfig + EditPlanClip 数据模型

新增领域实体

  • TemplateClipConfig: 模板片段配置(片段类型、时长范围、文案模板、素材要求、转场效果)
  • EditPlanClip: 剪辑计划片段(关联 EditPlan、实际素材、实际文案、排序、状态流转)

新增枚举

  • ClipType: intro/main/transition/outro/title/subtitle
  • TransitionEffect: cut/fade/slide_left/slide_right/dissolve/wipe
  • EditPlanClipStatus: pending/ready/rendered/failed

新增 ORM 模型 + Alembic 迁移

  • TemplateClipConfigModel → template_clip_configs 表
  • EditPlanClipModel → edit_plan_clips 表
  • 迁移 017: CREATE TABLE template_clip_configs + edit_plan_clips

新增仓储

  • SQLAlchemyTemplateClipConfigRepository
  • SQLAlchemyEditPlanClipRepository

测试

  • 44 个单元测试全部通过
## Phase 8 任务 2.02: TemplateClipConfig + EditPlanClip 数据模型 ### 新增领域实体 - **TemplateClipConfig**: 模板片段配置(片段类型、时长范围、文案模板、素材要求、转场效果) - **EditPlanClip**: 剪辑计划片段(关联 EditPlan、实际素材、实际文案、排序、状态流转) ### 新增枚举 - ClipType: intro/main/transition/outro/title/subtitle - TransitionEffect: cut/fade/slide_left/slide_right/dissolve/wipe - EditPlanClipStatus: pending/ready/rendered/failed ### 新增 ORM 模型 + Alembic 迁移 - TemplateClipConfigModel → template_clip_configs 表 - EditPlanClipModel → edit_plan_clips 表 - 迁移 017: CREATE TABLE template_clip_configs + edit_plan_clips ### 新增仓储 - SQLAlchemyTemplateClipConfigRepository - SQLAlchemyEditPlanClipRepository ### 测试 - 44 个单元测试全部通过
xiaoxia added 1 commit 2026-07-01 13:16:26 +08:00
feat(phase8-task202): TemplateClipConfig + EditPlanClip 数据模型、仓储、迁移与测试
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 191h33m32s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 191h33m35s
Deploy / Deploy Staging (push) Failing after 191h35m54s
CI/CD Pipeline / Frontend Lint (push) Failing after 191h36m27s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 191h36m32s
22bef9688f
新增领域实体:
- TemplateClipConfig: 模板片段配置(片段类型、时长范围、文案模板、素材要求、转场效果)
- EditPlanClip: 剪辑计划片段(关联 EditPlan、实际素材、实际文案、排序、状态流转)

新增枚举:
- ClipType: intro/main/transition/outro/title/subtitle
- TransitionEffect: cut/fade/slide_left/slide_right/dissolve/wipe
- EditPlanClipStatus: pending/ready/rendered/failed

新增 ORM 模型:
- TemplateClipConfigModel (template_clip_configs 表)
- EditPlanClipModel (edit_plan_clips 表)

新增仓储:
- SQLAlchemyTemplateClipConfigRepository (list_by_template/create/update/delete/delete_by_template)
- SQLAlchemyEditPlanClipRepository (list_by_plan/create/update/delete/delete_by_plan/count)

新增 Alembic 迁移 017: CREATE TABLE template_clip_configs + edit_plan_clips

单元测试 44 个全部通过
Author
Owner

代码审计 — PR #143 审查结果

结论: 通过,可合并

总体评价

Phase 8 任务 2.02 数据模型设计质量高,延续 Phase 8 任务 2.01 的六边形架构风格。枚举设计完备(ClipType 6 种 + TransitionEffect 6 种 + EditPlanClipStatus 4 种),StrEnum polyfill 兼容 Python <3.11。领域实体 dataclass(slots=True) 性能友好,状态机校验严谨。迁移脚本完整含 downgrade,仓储层 CRUD + 过滤查询齐全。44 个单元测试覆盖实体创建/校验/属性/状态流转/仓储 CRUD,正常+异常路径均有。

P3 建议(不阻塞合并)

1. 外键约束缺失(与 PR #141 同类型问题)

  • template_clip_configs.template_id → 应关联 edit_templates.id
  • edit_plan_clips.plan_id → 应关联 edit_plans.id
  • edit_plan_clips.template_clip_config_id → 应关联 template_clip_configs.id
  • 当前均为裸 String 无 FK,数据完整性依赖应用层。建议在后续迁移中补回 FK 约束

2. updated_at 缺少 onupdate 触发器

  • ORM 和迁移脚本中 updated_at 仅设 server_default=sa.func.now(),无自动更新
  • 依赖应用层每次 update 时手动设置(仓储层 _model_to_entity 传入 entity 的 updated_at)
  • 建议:添加 onupdate=sa.func.now() 防止遗漏

3. EditPlanClip 的 clip_type / transition_effect 类型为 str 而非枚举

  • TemplateClipConfig 使用 ClipType / TransitionEffect 枚举,EditPlanClip 使用 str
  • 两者通过 template_clip_config_id 关联,但 clip_type 没有类型约束一致性
  • 建议:EditPlanClip 也使用 ClipType 枚举,或在 create() 中添加 ClipType(clip_type) 验证

审查基于 commit 22bef968

## 代码审计 — PR #143 审查结果 **结论:✅ 通过,可合并** ### 总体评价 Phase 8 任务 2.02 数据模型设计质量高,延续 Phase 8 任务 2.01 的六边形架构风格。枚举设计完备(ClipType 6 种 + TransitionEffect 6 种 + EditPlanClipStatus 4 种),StrEnum polyfill 兼容 Python <3.11。领域实体 dataclass(slots=True) 性能友好,状态机校验严谨。迁移脚本完整含 downgrade,仓储层 CRUD + 过滤查询齐全。44 个单元测试覆盖实体创建/校验/属性/状态流转/仓储 CRUD,正常+异常路径均有。 ### P3 建议(不阻塞合并) **1. 外键约束缺失(与 PR #141 同类型问题)** - `template_clip_configs.template_id` → 应关联 `edit_templates.id` - `edit_plan_clips.plan_id` → 应关联 `edit_plans.id` - `edit_plan_clips.template_clip_config_id` → 应关联 `template_clip_configs.id` - 当前均为裸 String 无 FK,数据完整性依赖应用层。建议在后续迁移中补回 FK 约束 **2. updated_at 缺少 onupdate 触发器** - ORM 和迁移脚本中 `updated_at` 仅设 `server_default=sa.func.now()`,无自动更新 - 依赖应用层每次 update 时手动设置(仓储层 `_model_to_entity` 传入 entity 的 updated_at) - 建议:添加 `onupdate=sa.func.now()` 防止遗漏 **3. EditPlanClip 的 clip_type / transition_effect 类型为 str 而非枚举** - TemplateClipConfig 使用 ClipType / TransitionEffect 枚举,EditPlanClip 使用 str - 两者通过 `template_clip_config_id` 关联,但 clip_type 没有类型约束一致性 - 建议:EditPlanClip 也使用 ClipType 枚举,或在 create() 中添加 `ClipType(clip_type)` 验证 --- *审查基于 commit 22bef968*
xiaoxia closed this pull request 2026-07-01 14:28:32 +08:00
Some checks are pending
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 191h33m32s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 191h33m35s
Deploy / Deploy Staging (push) Failing after 191h35m54s
CI/CD Pipeline / Frontend Lint (push) Failing after 191h36m27s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 191h36m32s

Pull request closed

Sign in to join this conversation.