add endpoints to get items by id
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s

This commit is contained in:
Thomas Peetz
2026-05-20 18:34:44 +02:00
parent 944420802f
commit bbc00ae2cc
10 changed files with 114 additions and 25 deletions
+9 -1
View File
@@ -1,6 +1,6 @@
from typing import List
from fastapi import APIRouter
from fastapi import APIRouter, HTTPException
from src.db.models.tysc import Player
from src.db.session import SessionDep
@@ -17,3 +17,11 @@ def get_all_players(db: SessionDep) -> List[PlayerResponse]:
response = to_response(player)
results.append(response)
return results
@router.get("/players/{player_id}", response_model=PlayerResponse)
def get_player(player_id: str, db: SessionDep) -> PlayerResponse:
player = db.get(Player, player_id)
if player is None:
raise HTTPException(status_code=404, detail="Player could not be found")
response = to_response(player)
return response