cmvr-visual/backend/app/api/routes/batches.py
zhanghao 88cf14d794 feat: consolidate story studio and editable automatic production
Restructure backend and frontend modules; add story, library, and editor schema migrations.

Support editable automatic production, manual confirmation modes, account and user lifecycle management, compact container scrolling, consistent forms, and per-task result previews.

Update inference and TTS scheduling, deployment guidance, and regression coverage; remove obsolete standalone pages and temporary acceptance artifacts.
2026-11-14 14:07:26 +08:00

63 lines
1.7 KiB
Python

from fastapi import APIRouter, Depends, Header, Request
from app.core.security import Actor
from app.api.dependencies import csrf_actor, current_actor
from app.schemas.batches import BatchCreate, BatchControl
from app.services import batches as service
router = APIRouter(prefix="/batches", tags=["batches"])
@router.post("", status_code=202)
async def post_batch(
body: BatchCreate,
request: Request,
idempotency_key: str | None = Header(None),
actor: Actor = Depends(csrf_actor),
):
return await service.post_batch(
body=body, runtime=request.app.state, idempotency_key=idempotency_key, actor=actor
)
@router.get("")
async def list_batches(
request: Request, page: int = 1, page_size: int = 24, actor: Actor = Depends(current_actor)
):
return await service.list_batches(
runtime=request.app.state, page=page, page_size=page_size, actor=actor
)
@router.get("/{id}")
async def get_batch(id: str, request: Request, actor: Actor = Depends(current_actor)):
return await service.get_batch(id=id, runtime=request.app.state, actor=actor)
@router.delete("/{id}")
async def delete_batch(
id: str,
request: Request,
if_match: str | None = Header(None),
actor: Actor = Depends(csrf_actor),
):
return await service.delete_batch(
id=id, runtime=request.app.state, if_match=if_match, actor=actor
)
@router.post("/{id}/control")
async def batch_control(
id: str,
body: BatchControl,
request: Request,
idempotency_key: str | None = Header(None),
actor: Actor = Depends(csrf_actor),
):
return await service.batch_control(
id=id, body=body, runtime=request.app.state, idempotency_key=idempotency_key, actor=actor
)