25 lines
696 B
Python
25 lines
696 B
Python
# backend/app/routes/tournaments/matches.py
|
|
|
|
from fastapi import Depends, HTTPException
|
|
from sqlalchemy.orm import Session
|
|
|
|
from ... import crud, schemas
|
|
from ...database import get_db
|
|
from . import router
|
|
|
|
|
|
@router.get("/{id}/matches", response_model=list[schemas.MatchOut])
|
|
def get_tournament_matches(id: str, db: Session = Depends(get_db)):
|
|
matches = crud.get_tournament_matches(db, id)
|
|
return matches
|
|
|
|
|
|
@router.get("/{id}/matches/{match_id}", response_model=schemas.MatchOut)
|
|
def get_match_details(id: str, match_id: str, db: Session = Depends(get_db)):
|
|
match = crud.get_match(db, match_id)
|
|
|
|
if not match:
|
|
raise HTTPException(404, "Match not found")
|
|
|
|
return match
|