Backend
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
# 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, id, match_id)
|
||||
|
||||
if not match:
|
||||
raise HTTPException(404, "Match not found")
|
||||
|
||||
return match
|
||||
Reference in New Issue
Block a user