feat(phase2): 模板编辑器草稿 + 路由层 + 发布流程 #639

Merged
auto-approve-bot merged 1 commits from feat/phase2-template-editor into develop 2026-07-20 13:31:51 +08:00
Owner

概述

Phase 2 模板编辑器改造的第一步:新增后端路由和草稿管理机制。

核心变更

服务层 (EditTemplateService)

  • get_template_draft(template_id) — 通过 config.is_template_draft 查找草稿
  • create_template_draft(template_id, user_id) — 基于模板自动创建草稿
  • get_or_create_draft(template_id, user_id) — 首次访问自动创建
  • publish_template_from_draft(template_id, plan_id) — 草稿→模板发布(事务保证)

路由层 (templates_editor.py)

  • GET /templates/{id}/editor — 获取草稿详情
  • PUT /templates/{id}/editor — 更新草稿
  • POST /templates/{id}/editor/publish — 发布到模板
  • GET/POST/PUT/DELETE /templates/{id}/editor/clips — 片段CRUD

设计决策

  • 不新增表:草稿通过 config.is_template_draft=True 标记区分
  • 不复制业务代码:路由层全部转发到 EditPlanService
  • 原路由保持兼容/edit-plans/ 路径不变
  • 事务保证:发布时 config+clips 同步在一个事务里

测试

  • 新增8个单元测试覆盖草稿创建/查询/发布逻辑
  • 全部170个测试通过(edit_template_service + unified_render_service)

后续

  • Step 5: 原 /edit-plans/ 路由加 deprecated 标记
  • 子路由逐步迁移(BGM/转场/滤镜/AI/导出等)
  • 前端配合切换 API 路径

关联

  • 架构整合方案: /docs/edit_plan_architecture_consolidation.md
  • Phase 2 详细计划: /docs/phase2_template_editor_plan.md
## 概述 Phase 2 模板编辑器改造的第一步:新增后端路由和草稿管理机制。 ## 核心变更 ### 服务层 (`EditTemplateService`) - `get_template_draft(template_id)` — 通过 config.is_template_draft 查找草稿 - `create_template_draft(template_id, user_id)` — 基于模板自动创建草稿 - `get_or_create_draft(template_id, user_id)` — 首次访问自动创建 - `publish_template_from_draft(template_id, plan_id)` — 草稿→模板发布(事务保证) ### 路由层 (`templates_editor.py`) - `GET /templates/{id}/editor` — 获取草稿详情 - `PUT /templates/{id}/editor` — 更新草稿 - `POST /templates/{id}/editor/publish` — 发布到模板 - `GET/POST/PUT/DELETE /templates/{id}/editor/clips` — 片段CRUD ### 设计决策 - **不新增表**:草稿通过 `config.is_template_draft=True` 标记区分 - **不复制业务代码**:路由层全部转发到 `EditPlanService` - **原路由保持兼容**:`/edit-plans/` 路径不变 - **事务保证**:发布时 config+clips 同步在一个事务里 ## 测试 - 新增8个单元测试覆盖草稿创建/查询/发布逻辑 - 全部170个测试通过(edit_template_service + unified_render_service) ## 后续 - Step 5: 原 `/edit-plans/` 路由加 deprecated 标记 - 子路由逐步迁移(BGM/转场/滤镜/AI/导出等) - 前端配合切换 API 路径 ## 关联 - 架构整合方案: `/docs/edit_plan_architecture_consolidation.md` - Phase 2 详细计划: `/docs/phase2_template_editor_plan.md`
xiaoxia added 1 commit 2026-07-20 13:21:44 +08:00
feat(phase2): 模板编辑器草稿 + 路由层 + 发布流程
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 16s
AI Code Review / AI Code Review (pull_request) Failing after 28s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 4s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 38s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 4m43s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Successful in 4m4s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 7m19s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m51s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 10m4s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 17s
5c864d8971
- EditTemplateService 新增模板草稿方法: get/create/get_or_create/publish
- 新增 /templates/{template_id}/editor/ 路由前缀,7个核心端点
- 内部复用 EditPlanService,不复制业务逻辑
- 草稿通过 config.is_template_draft=True 标记,不新增表
- 发布使用事务保证 config + clips 同步一致
- 新增8个单元测试覆盖草稿/发布核心逻辑
auto-approve-bot approved these changes 2026-07-20 13:29:06 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。
auto-approve-bot approved these changes 2026-07-20 13:29:06 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。
auto-approve-bot merged commit 3bc7c3057a into develop 2026-07-20 13:31:51 +08:00
auto-approve-bot deleted branch feat/phase2-template-editor 2026-07-20 13:31:51 +08:00

🗑️ 预览环境已清理

PR #639 已关闭或合并,对应的预览环境已被清理。

如有需要,可以重新打开 PR 来重新生成预览环境。

🗑️ **预览环境已清理** PR #639 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Sign in to join this conversation.