Compare commits

...

19 Commits

Author SHA1 Message Date
Audit Bot f279b49a90 fix: 修复标题库新建/编辑功能 — 前后端字段名不匹配导致422
Tests / test (push) Failing after 1m3s
Tests / lint (push) Failing after 1m2s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
Deploy / Deploy Staging (push) Has been cancelled
Deploy / Build Production Runtime Images (push) Has been cancelled
Deploy / Deploy Production (push) Has been cancelled
Deploy / Production Browser E2E (push) Has been cancelled
根因:前端发送 { content, category } 但后端 CreateTitleLibraryRequest
期望 { name (必填), text (必填), category }。字段名不匹配导致
Pydantic 校验失败返回 422,modal 不关闭,数据不保存。

修复:
- api/titles.ts: 请求时将 content 映射为 text + 自动截取 name
- api/titles.ts: 响应时将后端 text 字段映射回前端 content
- api/titles.ts: updateTitle 改用 PUT(后端实际方法)
- 页面代码无需改动,映射在 API 层透明处理

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-28 22:00:36 +08:00
API文档维护Agent 97b436d016 fix: 禁用 redirect_slashes 修复 307 重定向导致前端新建失败
- FastAPI 初始化添加 redirect_slashes=False,避免反向代理后
  307 重定向 URL 丢失 HTTPS 协议
- 移除 titles.py/voices.py/generation_tasks.py 路由中的尾斜杠
  ('/' → '','/tasks/' → '/tasks','/tasks/{id}/results/' → '/tasks/{id}/results')

Fixes: 前端调用 POST /api/v1/titles 等接口时 307 重定向到 http:// 导致失败
2026-06-28 22:00:25 +08:00
xiaoxia 60afbf450d Merge pull request 'fix: [HOTFIX] 确保生产CORS始终包含saas.xiaoxiajianji.com' (#93) from fix/cors-production-domains into main
Tests / test (push) Failing after 1m3s
Tests / lint (push) Failing after 35s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
Deploy / Deploy Staging (push) Has been cancelled
Deploy / Build Production Runtime Images (push) Has been cancelled
Deploy / Deploy Production (push) Has been cancelled
Deploy / Production Browser E2E (push) Has been cancelled
2026-06-28 21:56:50 +08:00
API文档维护Agent 7545a5ccdc fix: 确保生产CORS始终包含saas.xiaoxiajianji.com
Tests / test (pull_request) Failing after 1m3s
Tests / lint (pull_request) Failing after 1m2s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Lint (pull_request) Has been cancelled
之前的修复只在CORS_ORIGINS为空时才添加默认域名,
但生产环境通过环境变量设置了CORS_ORIGINS_RAW,
导致saas子域仍然不在允许列表中。

现在无论CORS_ORIGINS_RAW如何配置,都会确保包含
xiaoxiajianji.com和saas.xiaoxiajianji.com。
2026-06-28 21:56:21 +08:00
xiaoxia e56678455d Merge pull request 'fix: [HOTFIX] 修复标题/配音创建500、素材库列表500、CORS配置' (#92) from fix/api-500-hotfix into main
Tests / test (push) Failing after 32s
Tests / lint (push) Failing after 34s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
Deploy / Deploy Staging (push) Has been cancelled
Deploy / Build Production Runtime Images (push) Has been cancelled
Deploy / Deploy Production (push) Has been cancelled
Deploy / Production Browser E2E (push) Has been cancelled
2026-06-28 21:40:09 +08:00
API文档维护Agent 6f00dce56e fix: 修复标题/配音创建500、素材库列表500、CORS缺失
Tests / test (pull_request) Failing after 33s
Tests / lint (pull_request) Failing after 1m8s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Lint (pull_request) Has been cancelled
- titles.py/voices.py: get_by_id → find_by_id(方法名错误导致AttributeError)
- project_repository.py: cast shared_users to JSONB for @> operator(JSON列不支持@>)
- main.py: CORS allow_origins 添加 https://saas.xiaoxiajianji.com
2026-06-28 21:39:03 +08:00
CI Test 7beeecd467 Merge remote main (PR#71 Worker mem limit) into release v0.1.71
Tests / test (push) Failing after 1s
Tests / lint (push) Failing after 1s
Auto Merge PRs / auto-merge (push) Failing after 43s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
Deploy / Deploy Staging (push) Has been cancelled
Deploy / Build Production Runtime Images (push) Has been cancelled
Deploy / Deploy Production (push) Has been cancelled
Deploy / Production Browser E2E (push) Has been cancelled
2026-06-28 18:17:17 +08:00
CI Test 79cc6b0dcc Release v0.1.71: Phase 1 核心重构 + Phase 2 查重/订阅前端/后端 + P0 修复 2026-06-28 18:16:42 +08:00
xiaoxia 40cbc6a010 Merge pull request 'chore: merge develop to main (Worker内存限制持久化)' (#71) from develop into main
Tests / test (push) Failing after 1s
Tests / lint (push) Failing after 0s
Auto Merge PRs / auto-merge (push) Failing after 40s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
Deploy / Deploy Staging (push) Has been cancelled
Deploy / Build Production Runtime Images (push) Has been cancelled
Deploy / Deploy Production (push) Has been cancelled
Deploy / Production Browser E2E (push) Has been cancelled
2026-06-28 13:07:50 +08:00
CI Test abd2ee63da fix:彻底清除 ProjectGeneration.tsx 中未使用的 scale 变量
Tests / test (push) Failing after 1s
Tests / lint (push) Failing after 0s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
Deploy / Deploy Staging (push) Has been cancelled
Deploy / Build Production Runtime Images (push) Has been cancelled
Deploy / Deploy Production (push) Has been cancelled
Deploy / Production Browser E2E (push) Has been cancelled
2026-06-28 11:21:15 +08:00
CI Test 3292a5d655 fix: 持久化 api/worker 容器内存限制,改用 mem_limit: 2g 替代 deploy.resources.limits.memory 2026-06-28 11:19:50 +08:00
CI Test 1ea75e5d33 fix: resolve all TS6133 unused variable errors (Plans, ProjectGeneration, ProjectTasks)
Tests / test (push) Failing after 1s
Tests / lint (push) Failing after 1s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
Deploy / Deploy Staging (push) Has been cancelled
Deploy / Build Production Runtime Images (push) Has been cancelled
Deploy / Deploy Production (push) Has been cancelled
Deploy / Production Browser E2E (push) Has been cancelled
2026-06-28 11:18:55 +08:00
CI Test e418577097 fix: resolve TypeScript unused variable errors in ProjectGeneration.tsx and ProjectTasks.tsx
Tests / test (push) Failing after 1s
Tests / lint (push) Failing after 0s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
Deploy / Deploy Staging (push) Has been cancelled
Deploy / Build Production Runtime Images (push) Has been cancelled
Deploy / Deploy Production (push) Has been cancelled
Deploy / Production Browser E2E (push) Has been cancelled
2026-06-28 11:14:47 +08:00
xiaoxia 02f21e0f1d Merge pull request 'fix: 后端代码健康修复 (P1-1/P1-2/P2-1/P2-2/P2-3)' (#68) from develop into main
Tests / test (push) Failing after 0s
Tests / lint (push) Failing after 0s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
Deploy / Deploy Staging (push) Has been cancelled
Deploy / Build Production Runtime Images (push) Has been cancelled
Deploy / Deploy Production (push) Has been cancelled
Deploy / Production Browser E2E (push) Has been cancelled
2026-06-28 10:48:47 +08:00
CI Test 3ce406d4ce release: merge develop into main for v0.1.69
Tests / test (push) Failing after 0s
Tests / lint (push) Failing after 0s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
Deploy / Deploy Staging (push) Has been cancelled
Deploy / Build Production Runtime Images (push) Has been cancelled
Deploy / Deploy Production (push) Has been cancelled
Deploy / Production Browser E2E (push) Has been cancelled
2026-06-28 10:12:16 +08:00
CI Test ff3fdfb451 release: merge develop into main for v0.1.68
Tests / test (push) Failing after 0s
Tests / lint (push) Failing after 0s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
Deploy / Deploy Staging (push) Has been cancelled
Deploy / Build Production Runtime Images (push) Has been cancelled
Deploy / Deploy Production (push) Has been cancelled
Deploy / Production Browser E2E (push) Has been cancelled
2026-06-28 09:45:31 +08:00
CI Test 93e0ec5ea4 Merge branch 'main' of https://git.xiaoxiajianji.com/xiaoxia/xiaoxia-saas 2026-06-28 09:45:17 +08:00
xiaoxia 926d0fa272 fix: 为所有 ORM 模型添加外键约束及级联删除策略 (#65)
Tests / test (push) Failing after 0s
Tests / lint (push) Failing after 0s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
Deploy / Deploy Staging (push) Has been cancelled
Deploy / Build Production Runtime Images (push) Has been cancelled
Deploy / Deploy Production (push) Has been cancelled
Deploy / Production Browser E2E (push) Has been cancelled
2026-06-28 08:47:51 +08:00
CI Test ebcfa7280d fix: 修复 password_reset_use_case 循环导入问题 2026-06-27 21:30:47 +08:00
9 changed files with 284 additions and 29 deletions
@@ -0,0 +1,190 @@
"""add foreign key constraints and missing indexes
Revision ID: 010
Revises: 009
Create Date: 2026-06-28
Summary:
- Add ForeignKey constraints to all 35 logical FK columns across 16 tables
- ON DELETE CASCADE for parent-child relationships (project → children)
- ON DELETE SET NULL for optional user references (created_by, assignee, etc.)
- Add missing indexes on 10 FK columns
- Alter columns from NOT NULL to nullable where SET NULL is needed
"""
from alembic import op
import sqlalchemy as sa
revision = "010"
down_revision = "009"
branch_labels = None
depends_on = None
def upgrade() -> None:
# ── projects ──────────────────────────────────────────────
op.create_foreign_key("fk_projects_owner_user_id", "projects", "users", ["owner_user_id"], ["id"], ondelete="CASCADE")
# ── asset_libraries ───────────────────────────────────────
op.create_foreign_key("fk_asset_libraries_project_id", "asset_libraries", "projects", ["project_id"], ["id"], ondelete="CASCADE")
# ── assets ────────────────────────────────────────────────
# uploaded_by_user_id: nullable=False → nullable=True for SET NULL
op.alter_column("assets", "uploaded_by_user_id", existing_type=sa.String(36), nullable=True)
op.create_foreign_key("fk_assets_project_id", "assets", "projects", ["project_id"], ["id"], ondelete="CASCADE")
op.create_foreign_key("fk_assets_asset_library_id", "assets", "asset_libraries", ["asset_library_id"], ["id"], ondelete="CASCADE")
op.create_foreign_key("fk_assets_uploaded_by_user_id", "assets", "users", ["uploaded_by_user_id"], ["id"], ondelete="SET NULL")
# Add missing index
op.create_index("ix_assets_uploaded_by_user_id", "assets", ["uploaded_by_user_id"])
# ── project_titles ────────────────────────────────────────
# created_by_user_id: nullable=False → nullable=True for SET NULL
op.alter_column("project_titles", "created_by_user_id", existing_type=sa.String(36), nullable=True)
op.create_foreign_key("fk_project_titles_project_id", "project_titles", "projects", ["project_id"], ["id"], ondelete="CASCADE")
op.create_foreign_key("fk_project_titles_created_by_user_id", "project_titles", "users", ["created_by_user_id"], ["id"], ondelete="SET NULL")
# Add missing index
op.create_index("ix_project_titles_created_by_user_id", "project_titles", ["created_by_user_id"])
# ── edit_templates ────────────────────────────────────────
# created_by_user_id: nullable=False → nullable=True for SET NULL
op.alter_column("edit_templates", "created_by_user_id", existing_type=sa.String(32), nullable=True)
op.create_foreign_key("fk_edit_templates_project_id", "edit_templates", "projects", ["project_id"], ["id"], ondelete="CASCADE")
op.create_foreign_key("fk_edit_templates_created_by_user_id", "edit_templates", "users", ["created_by_user_id"], ["id"], ondelete="SET NULL")
# ── edit_plans ────────────────────────────────────────────
# title_id: nullable=False → nullable=True for SET NULL
# created_by_user_id: nullable=False → nullable=True for SET NULL
op.alter_column("edit_plans", "title_id", existing_type=sa.String(32), nullable=True)
op.alter_column("edit_plans", "created_by_user_id", existing_type=sa.String(32), nullable=True)
op.create_foreign_key("fk_edit_plans_project_id", "edit_plans", "projects", ["project_id"], ["id"], ondelete="CASCADE")
op.create_foreign_key("fk_edit_plans_template_id", "edit_plans", "edit_templates", ["template_id"], ["id"], ondelete="CASCADE")
op.create_foreign_key("fk_edit_plans_asset_library_id", "edit_plans", "asset_libraries", ["asset_library_id"], ["id"], ondelete="CASCADE")
op.create_foreign_key("fk_edit_plans_title_id", "edit_plans", "project_titles", ["title_id"], ["id"], ondelete="SET NULL")
op.create_foreign_key("fk_edit_plans_created_by_user_id", "edit_plans", "users", ["created_by_user_id"], ["id"], ondelete="SET NULL")
# ── edit_plan_clips ───────────────────────────────────────
op.create_foreign_key("fk_edit_plan_clips_edit_plan_id", "edit_plan_clips", "edit_plans", ["edit_plan_id"], ["id"], ondelete="CASCADE")
op.create_foreign_key("fk_edit_plan_clips_asset_id", "edit_plan_clips", "assets", ["asset_id"], ["id"], ondelete="CASCADE")
# ── ingest_jobs ───────────────────────────────────────────
# result_asset_id: nullable=False → nullable=True for SET NULL
op.alter_column("ingest_jobs", "result_asset_id", existing_type=sa.String(32), nullable=True)
op.create_foreign_key("fk_ingest_jobs_project_id", "ingest_jobs", "projects", ["project_id"], ["id"], ondelete="CASCADE")
op.create_foreign_key("fk_ingest_jobs_library_id", "ingest_jobs", "asset_libraries", ["library_id"], ["id"], ondelete="CASCADE")
op.create_foreign_key("fk_ingest_jobs_result_asset_id", "ingest_jobs", "assets", ["result_asset_id"], ["id"], ondelete="SET NULL")
# ── classification_jobs ───────────────────────────────────
op.create_foreign_key("fk_classification_jobs_project_id", "classification_jobs", "projects", ["project_id"], ["id"], ondelete="CASCADE")
op.create_foreign_key("fk_classification_jobs_asset_id", "classification_jobs", "assets", ["asset_id"], ["id"], ondelete="CASCADE")
# ── generation_tasks ──────────────────────────────────────
# edit_plan_id: nullable=False → nullable=True for SET NULL
# created_by_user_id: nullable=False → nullable=True for SET NULL
op.alter_column("generation_tasks", "edit_plan_id", existing_type=sa.String(32), nullable=True)
op.alter_column("generation_tasks", "created_by_user_id", existing_type=sa.String(32), nullable=True)
op.create_foreign_key("fk_generation_tasks_project_id", "generation_tasks", "projects", ["project_id"], ["id"], ondelete="CASCADE")
op.create_foreign_key("fk_generation_tasks_asset_library_id", "generation_tasks", "asset_libraries", ["asset_library_id"], ["id"], ondelete="CASCADE")
op.create_foreign_key("fk_generation_tasks_edit_plan_id", "generation_tasks", "edit_plans", ["edit_plan_id"], ["id"], ondelete="SET NULL")
op.create_foreign_key("fk_generation_tasks_created_by_user_id", "generation_tasks", "users", ["created_by_user_id"], ["id"], ondelete="SET NULL")
# ── generated_videos ──────────────────────────────────────
op.create_foreign_key("fk_generated_videos_project_id", "generated_videos", "projects", ["project_id"], ["id"], ondelete="CASCADE")
op.create_foreign_key("fk_generated_videos_generation_task_id", "generated_videos", "generation_tasks", ["generation_task_id"], ["id"], ondelete="CASCADE")
op.create_foreign_key("fk_generated_videos_duplicate_of", "generated_videos", "generated_videos", ["duplicate_of"], ["id"], ondelete="SET NULL")
# ── tasks ─────────────────────────────────────────────────
# parent_task_id: nullable=False → nullable=True for SET NULL
# assignee_user_id: nullable=False → nullable=True for SET NULL
op.alter_column("tasks", "parent_task_id", existing_type=sa.String(32), nullable=True)
op.alter_column("tasks", "assignee_user_id", existing_type=sa.String(32), nullable=True)
op.create_foreign_key("fk_tasks_project_id", "tasks", "projects", ["project_id"], ["id"], ondelete="CASCADE")
op.create_foreign_key("fk_tasks_parent_task_id", "tasks", "tasks", ["parent_task_id"], ["id"], ondelete="SET NULL")
op.create_foreign_key("fk_tasks_assignee_user_id", "tasks", "users", ["assignee_user_id"], ["id"], ondelete="SET NULL")
# ── milestones ────────────────────────────────────────────
op.create_foreign_key("fk_milestones_project_id", "milestones", "projects", ["project_id"], ["id"], ondelete="CASCADE")
# ── task_issues ───────────────────────────────────────────
# created_by_user_id: nullable=False → nullable=True for SET NULL
op.alter_column("task_issues", "created_by_user_id", existing_type=sa.String(32), nullable=True)
op.create_foreign_key("fk_task_issues_task_id", "task_issues", "tasks", ["task_id"], ["id"], ondelete="CASCADE")
op.create_foreign_key("fk_task_issues_project_id", "task_issues", "projects", ["project_id"], ["id"], ondelete="CASCADE")
op.create_foreign_key("fk_task_issues_created_by_user_id", "task_issues", "users", ["created_by_user_id"], ["id"], ondelete="SET NULL")
def downgrade() -> None:
# ── task_issues ───────────────────────────────────────────
op.drop_constraint("fk_task_issues_created_by_user_id", "task_issues", type_="foreignkey")
op.drop_constraint("fk_task_issues_project_id", "task_issues", type_="foreignkey")
op.drop_constraint("fk_task_issues_task_id", "task_issues", type_="foreignkey")
op.alter_column("task_issues", "created_by_user_id", existing_type=sa.String(32), nullable=False)
# ── milestones ────────────────────────────────────────────
op.drop_constraint("fk_milestones_project_id", "milestones", type_="foreignkey")
# ── tasks ─────────────────────────────────────────────────
op.drop_constraint("fk_tasks_assignee_user_id", "tasks", type_="foreignkey")
op.drop_constraint("fk_tasks_parent_task_id", "tasks", type_="foreignkey")
op.drop_constraint("fk_tasks_project_id", "tasks", type_="foreignkey")
op.alter_column("tasks", "assignee_user_id", existing_type=sa.String(32), nullable=False)
op.alter_column("tasks", "parent_task_id", existing_type=sa.String(32), nullable=False)
# ── generated_videos ──────────────────────────────────────
op.drop_constraint("fk_generated_videos_duplicate_of", "generated_videos", type_="foreignkey")
op.drop_constraint("fk_generated_videos_generation_task_id", "generated_videos", type_="foreignkey")
op.drop_constraint("fk_generated_videos_project_id", "generated_videos", type_="foreignkey")
# ── generation_tasks ──────────────────────────────────────
op.drop_constraint("fk_generation_tasks_created_by_user_id", "generation_tasks", type_="foreignkey")
op.drop_constraint("fk_generation_tasks_edit_plan_id", "generation_tasks", type_="foreignkey")
op.drop_constraint("fk_generation_tasks_asset_library_id", "generation_tasks", type_="foreignkey")
op.drop_constraint("fk_generation_tasks_project_id", "generation_tasks", type_="foreignkey")
op.alter_column("generation_tasks", "created_by_user_id", existing_type=sa.String(32), nullable=False)
op.alter_column("generation_tasks", "edit_plan_id", existing_type=sa.String(32), nullable=False)
# ── classification_jobs ───────────────────────────────────
op.drop_constraint("fk_classification_jobs_asset_id", "classification_jobs", type_="foreignkey")
op.drop_constraint("fk_classification_jobs_project_id", "classification_jobs", type_="foreignkey")
# ── ingest_jobs ───────────────────────────────────────────
op.drop_constraint("fk_ingest_jobs_result_asset_id", "ingest_jobs", type_="foreignkey")
op.drop_constraint("fk_ingest_jobs_library_id", "ingest_jobs", type_="foreignkey")
op.drop_constraint("fk_ingest_jobs_project_id", "ingest_jobs", type_="foreignkey")
op.alter_column("ingest_jobs", "result_asset_id", existing_type=sa.String(32), nullable=False)
# ── edit_plan_clips ───────────────────────────────────────
op.drop_constraint("fk_edit_plan_clips_asset_id", "edit_plan_clips", type_="foreignkey")
op.drop_constraint("fk_edit_plan_clips_edit_plan_id", "edit_plan_clips", type_="foreignkey")
# ── edit_plans ────────────────────────────────────────────
op.drop_constraint("fk_edit_plans_created_by_user_id", "edit_plans", type_="foreignkey")
op.drop_constraint("fk_edit_plans_title_id", "edit_plans", type_="foreignkey")
op.drop_constraint("fk_edit_plans_asset_library_id", "edit_plans", type_="foreignkey")
op.drop_constraint("fk_edit_plans_template_id", "edit_plans", type_="foreignkey")
op.drop_constraint("fk_edit_plans_project_id", "edit_plans", type_="foreignkey")
op.alter_column("edit_plans", "created_by_user_id", existing_type=sa.String(32), nullable=False)
op.alter_column("edit_plans", "title_id", existing_type=sa.String(32), nullable=False)
# ── edit_templates ────────────────────────────────────────
op.drop_constraint("fk_edit_templates_created_by_user_id", "edit_templates", type_="foreignkey")
op.drop_constraint("fk_edit_templates_project_id", "edit_templates", type_="foreignkey")
op.alter_column("edit_templates", "created_by_user_id", existing_type=sa.String(32), nullable=False)
# ── project_titles ────────────────────────────────────────
op.drop_index("ix_project_titles_created_by_user_id", table_name="project_titles")
op.drop_constraint("fk_project_titles_created_by_user_id", "project_titles", type_="foreignkey")
op.drop_constraint("fk_project_titles_project_id", "project_titles", type_="foreignkey")
op.alter_column("project_titles", "created_by_user_id", existing_type=sa.String(36), nullable=False)
# ── assets ────────────────────────────────────────────────
op.drop_index("ix_assets_uploaded_by_user_id", table_name="assets")
op.drop_constraint("fk_assets_uploaded_by_user_id", "assets", type_="foreignkey")
op.drop_constraint("fk_assets_asset_library_id", "assets", type_="foreignkey")
op.drop_constraint("fk_assets_project_id", "assets", type_="foreignkey")
op.alter_column("assets", "uploaded_by_user_id", existing_type=sa.String(36), nullable=False)
# ── asset_libraries ───────────────────────────────────────
op.drop_constraint("fk_asset_libraries_project_id", "asset_libraries", type_="foreignkey")
# ── projects ──────────────────────────────────────────────
op.drop_constraint("fk_projects_owner_user_id", "projects", type_="foreignkey")
+2 -2
View File
@@ -79,7 +79,7 @@ def _ensure_library_has_ready_video_assets(assets) -> None:
)
@router.post("/tasks/", response_model=GenerationTaskResponse)
@router.post("/tasks", response_model=GenerationTaskResponse)
def create_generation_task(
request: CreateGenerationTaskRequest,
authenticated_user: AuthenticatedUser = Depends(get_current_user),
@@ -130,7 +130,7 @@ def get_generation_task(
return _to_generation_task_response(task)
@router.get("/tasks/{task_id}/results/", response_model=ListGeneratedVideosResponse)
@router.get("/tasks/{task_id}/results", response_model=ListGeneratedVideosResponse)
def list_generation_results(
task_id: str,
authenticated_user: AuthenticatedUser = Depends(get_current_user),
+3 -3
View File
@@ -51,13 +51,13 @@ def _to_response(item) -> TitleLibraryItemResponse:
def _get_user_plan(user_id: str, user_repository: UserRepository) -> str:
user = user_repository.get_by_id(user_id)
user = user_repository.find_by_id(user_id)
if user is None:
return "free"
return getattr(user, "subscription_plan", "free") or "free"
@router.get("/", response_model=ListTitleLibraryResponse)
@router.get("", response_model=ListTitleLibraryResponse)
def list_titles(
category: Optional[str] = Query(None),
skip: int = Query(0, ge=0),
@@ -89,7 +89,7 @@ def get_title(
return _to_response(item)
@router.post("/", response_model=TitleLibraryItemResponse, status_code=status.HTTP_201_CREATED)
@router.post("", response_model=TitleLibraryItemResponse, status_code=status.HTTP_201_CREATED)
def create_title(
request: CreateTitleLibraryRequest,
authenticated_user: AuthenticatedUser = Depends(get_current_user),
+3 -3
View File
@@ -55,13 +55,13 @@ def _to_response(item) -> VoiceLibraryItemResponse:
def _get_user_plan(user_id: str, user_repository: UserRepository) -> str:
user = user_repository.get_by_id(user_id)
user = user_repository.find_by_id(user_id)
if user is None:
return "free"
return getattr(user, "subscription_plan", "free") or "free"
@router.get("/", response_model=ListVoiceLibraryResponse)
@router.get("", response_model=ListVoiceLibraryResponse)
def list_voices(
status_filter: Optional[str] = Query(None, alias="status"),
skip: int = Query(0, ge=0),
@@ -93,7 +93,7 @@ def get_voice(
return _to_response(item)
@router.post("/", response_model=VoiceLibraryItemResponse, status_code=status.HTTP_201_CREATED)
@router.post("", response_model=VoiceLibraryItemResponse, status_code=status.HTTP_201_CREATED)
def create_voice(
request: CreateVoiceLibraryRequest,
authenticated_user: AuthenticatedUser = Depends(get_current_user),
+1 -1
View File
@@ -14,4 +14,4 @@ class IngestJobResponse(BaseModel):
storage_key: str
status: str
error_message: str
result_asset_id: str
result_asset_id: str | None
+6 -4
View File
@@ -24,6 +24,7 @@ app = FastAPI(
version=settings.APP_VERSION,
docs_url="/docs",
redoc_url="/redoc",
redirect_slashes=False,
)
app.add_exception_handler(APIException, api_exception_handler)
@@ -38,10 +39,11 @@ if settings.DEBUG:
allow_origins = settings.CORS_ORIGINS # Allow localhost in debug mode
else:
# In production, filter out any wildcard "*" origins
allow_origins = [origin for origin in settings.CORS_ORIGINS if origin != "*"]
if not allow_origins:
# Default to production domain if no valid origins configured
allow_origins = ["https://xiaoxiajianji.com"]
allow_origins = list({origin for origin in settings.CORS_ORIGINS if origin != "*"})
# Always ensure production domains are included
for domain in ("https://xiaoxiajianji.com", "https://saas.xiaoxiajianji.com"):
if domain not in allow_origins:
allow_origins.append(domain)
app.add_middleware(
CORSMiddleware,
+73 -11
View File
@@ -1,10 +1,11 @@
/**
* 标题相关 API
* Phase 1 新增:全局标题库
* 注意:后端 schema 使用 name + text 字段,前端 UI 用 content 展示
*/
import apiClient from './client';
/** 标题条目 */
/** 标题条目(前端展示用) */
export interface TitleItem {
id: string;
content: string;
@@ -16,7 +17,50 @@ export interface TitleItem {
updated_at?: string;
}
/** 创建标题请求 */
/** 后端标题响应格式 */
interface BackendTitleResponse {
id: string;
user_id: string;
name: string;
text: string;
category: string;
description: string;
tags: string[];
usage_count: number;
is_active: boolean;
created_at: string;
updated_at: string;
}
/** 后端创建标题请求格式 */
interface BackendCreateTitleRequest {
name: string;
text: string;
category: string;
description?: string;
tags?: string[];
}
/** 后端更新标题请求格式 */
interface BackendUpdateTitleRequest {
name?: string;
text?: string;
category?: string;
description?: string;
tags?: string[];
}
/** 将后端响应映射为前端 TitleItem */
const toTitleItem = (item: BackendTitleResponse): TitleItem => ({
id: item.id,
content: item.text,
category: item.category,
word_count: item.text?.length || 0,
created_at: item.created_at,
updated_at: item.updated_at,
});
/** 创建标题请求(前端接口,保持向后兼容) */
export interface CreateTitleRequest {
content: string;
category?: string;
@@ -24,25 +68,43 @@ export interface CreateTitleRequest {
/** 获取当前用户的所有标题 */
export const getTitles = async (): Promise<TitleItem[]> => {
const response = await apiClient.get('/titles');
return response.data.items || response.data || [];
const response = await apiClient.get<{ items: BackendTitleResponse[] }>('/titles');
return (response.data.items || []).map(toTitleItem);
};
/** 创建标题 */
export const createTitle = async (
data: CreateTitleRequest
data: CreateTitleRequest,
): Promise<TitleItem> => {
const response = await apiClient.post('/titles', data);
return response.data;
// 后端要求 name(≤255)和 text(≤500),name 从 content 截取
const payload: BackendCreateTitleRequest = {
name: data.content.slice(0, 255),
text: data.content.slice(0, 500),
category: data.category || 'default',
};
const response = await apiClient.post<BackendTitleResponse>('/titles', payload);
return toTitleItem(response.data);
};
/** 更新标题 */
export const updateTitle = async (
titleId: string,
data: Partial<CreateTitleRequest>
data: Partial<CreateTitleRequest>,
): Promise<TitleItem> => {
const response = await apiClient.patch(`/titles/${titleId}`, data);
return response.data;
const payload: BackendUpdateTitleRequest = {};
if (data.content !== undefined) {
payload.name = data.content.slice(0, 255);
payload.text = data.content.slice(0, 500);
}
if (data.category !== undefined) {
payload.category = data.category;
}
// 后端用 PUT,非 PATCH
const response = await apiClient.put<BackendTitleResponse>(
`/titles/${titleId}`,
payload,
);
return toTitleItem(response.data);
};
/** 删除标题 */
@@ -52,7 +114,7 @@ export const deleteTitle = async (titleId: string): Promise<void> => {
/** 批量导入标题 */
export const batchImportTitles = async (
titles: string[]
titles: string[],
): Promise<{ imported_count: number }> => {
const response = await apiClient.post('/titles/batch-import', { titles });
return response.data;
+2 -2
View File
@@ -72,11 +72,11 @@ services:
# =========================================
# 资源限制建议(生产环境建议启用)
# =========================================
mem_limit: 2g
deploy:
resources:
limits:
cpus: '2.0'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M
@@ -112,11 +112,11 @@ services:
# 资源限制建议(生产环境建议启用)
# =========================================
# 注意: Worker 需要处理视频,建议分配更多资源
mem_limit: 2g
deploy:
resources:
limits:
cpus: '2.0'
memory: 2G
reservations:
cpus: '0.5'
memory: 1G
@@ -54,12 +54,13 @@ class SQLAlchemyProjectRepository:
def find_accessible_projects(self, user_id: str) -> list[Project]:
"""查找用户可访问的所有项目(自己拥有的 + 被共享的)"""
from sqlalchemy import or_
from sqlalchemy import or_, cast
from sqlalchemy.dialects.postgresql import JSONB
models = self.session.query(ProjectModel).filter(
or_(
ProjectModel.owner_user_id == user_id,
ProjectModel.shared_users.contains([user_id])
cast(ProjectModel.shared_users, JSONB).contains([user_id])
)
).all()
return [self._to_entity(model) for model in models]