Code refactoring. Add support genres and actors to routes

This commit is contained in:
2024-06-26 23:13:47 +04:00
parent fc3bcc343d
commit b9e22fcc4c
28 changed files with 545 additions and 250 deletions

22
routes/game_genres.py Normal file
View File

@@ -0,0 +1,22 @@
from sqlalchemy.ext.asyncio import AsyncSession
from fastapi import APIRouter, Depends, HTTPException, status
from database import *
from file_handler import *
from routes.auth import get_user
game_genres_router = APIRouter(
prefix="/genres/games", tags=["Games", "Genres"])
@game_genres_router.get("", response_model=list[GameGenre])
async def get_game_genres(db_session: AsyncSession = Depends(Database.get_session)):
return await GameGenresCRUD.get_all(db_session)
@game_genres_router.post("", response_model=GameGenre)
async def add_game_genre(genre: GameGenreCreate,
user: User = Depends(get_user),
db_session: AsyncSession = Depends(Database.get_session)):
return await GameGenresCRUD.add(db_session, genre)