第一次提交

This commit is contained in:
2026-08-01 16:50:55 +08:00
commit c8f9e39039
68 changed files with 6016 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
"""任务状态查询(前端轮询)。"""
from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from app.db import get_db
from app.deps import get_current_user
from app.models.job import ProcessingJob
from app.models.user import User
from app.schemas.job import JobOut
router = APIRouter(prefix="/api/jobs", tags=["jobs"])
@router.get("/{job_id}", response_model=JobOut)
async def get_job(
job_id: str,
db: AsyncSession = Depends(get_db),
current: User = Depends(get_current_user),
):
job = await db.scalar(
select(ProcessingJob).where(
ProcessingJob.id == job_id, ProcessingJob.user_id == current.id
)
)
if job is None:
raise HTTPException(status.HTTP_404_NOT_FOUND, detail="任务不存在")
return job