M1: FastAPI 分层后端(judge.engine hydro/judge0 + AI 多厂商) + 前端工作台(真实API/速查表/公式小课堂)
这个提交包含在:
@@ -0,0 +1,24 @@
|
||||
"""题目 API:列表与详情(含选择题、LaTeX 用法解释)。"""
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.core.db import get_session
|
||||
from app.repositories.problem_repo import ProblemRepo
|
||||
|
||||
router = APIRouter(prefix="/problems", tags=["problems"])
|
||||
|
||||
|
||||
@router.get("")
|
||||
async def list_problems(course: str | None = None, session: Session = Depends(get_session)):
|
||||
rows = ProblemRepo(session).list_by_course(course)
|
||||
return [p.to_dict() for p in rows]
|
||||
|
||||
|
||||
@router.get("/{pid}")
|
||||
async def get_problem(pid: int, session: Session = Depends(get_session)):
|
||||
row = ProblemRepo(session).get(pid)
|
||||
if not row:
|
||||
raise HTTPException(404, "题目不存在")
|
||||
return row.to_dict()
|
||||
在新工单中引用
屏蔽一个用户