# -*- coding: utf-8 -*- from fastapi import Path, Depends from sqlalchemy.ext.asyncio import AsyncSession from crud.paper import crud_question from models.user import Teacher from utils.depends import get_async_db, get_current_user async def get_paper_questions( page: int = 1, size: int = 10, pid: int = Path(..., description="试卷ID"), db: AsyncSession = Depends(get_async_db), current_user: Teacher = Depends(get_current_user)): # 分页 offset = (page - 1) * size total, db_questions = await crud_question.find_all(db, filters={"pid": pid}, offset=offset, limit=size) return {"data": db_questions, "total": total}