This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from typing import List
|
||||
from fastapi import APIRouter
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
from src.core.log_conf import logger
|
||||
from src.db.session import SessionDep
|
||||
from src.schema.tysc.sport import SportResponse, to_response
|
||||
from src.db.models.tysc import Sport
|
||||
@@ -15,3 +16,13 @@ def get_all_sports(db: SessionDep) -> List[SportResponse]:
|
||||
response = to_response(sport)
|
||||
results.append(response)
|
||||
return results
|
||||
|
||||
@router.get("/sports/{sport_id}", response_model=SportResponse)
|
||||
def get_sport(sport_id: str, db: SessionDep) -> SportResponse:
|
||||
sport = db.get(Sport, sport_id)
|
||||
if sport is None:
|
||||
raise HTTPException(status_code=404, detail="Sport could not be found")
|
||||
logger.debug(f"create SportResponse for {sport}")
|
||||
response: SportResponse = to_response(sport)
|
||||
return response
|
||||
|
||||
|
||||
Reference in New Issue
Block a user