This commit is contained in:
@@ -1,18 +1,26 @@
|
||||
from typing import List
|
||||
|
||||
from fastapi import APIRouter
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
from src.db.models.comic import StoryArc
|
||||
from src.db.session import SessionDep
|
||||
from src.schema.comics.storyarc import StoryArcResponse, to_response
|
||||
from src.schema.comics.storyarc import StoryArcResponse, storyarc_to_response
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/storyarcs", response_model=List[StoryArcResponse])
|
||||
def get_issues(db: SessionDep) -> List[StoryArcResponse]:
|
||||
def get_storyarcs(db: SessionDep) -> List[StoryArcResponse]:
|
||||
results: List[StoryArcResponse] = []
|
||||
storyarcs = db.query(StoryArc).all()
|
||||
for storyarc in storyarcs:
|
||||
response = to_response(storyarc)
|
||||
response = storyarc_to_response(storyarc)
|
||||
results.append(response)
|
||||
return results
|
||||
|
||||
@router.get("/storyarcs/{storyarc_id}", response_model=StoryArcResponse)
|
||||
def get_storyarc(story_arc_id: str, db: SessionDep) -> StoryArcResponse:
|
||||
storyarc = db.get(StoryArc, story_arc_id)
|
||||
if storyarc is None:
|
||||
raise HTTPException(status_code=404, detail="Storyarc could not be found")
|
||||
response = storyarc_to_response(storyarc)
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user