update models to use string type for id fields
This commit is contained in:
@@ -7,30 +7,14 @@ from src.db.models.comic import Artist
|
||||
|
||||
|
||||
class ArtistCreation(BaseModel):
|
||||
id: str
|
||||
name: str
|
||||
|
||||
class ArtistResponse(BaseModel):
|
||||
id: UUID
|
||||
id: str
|
||||
name: str
|
||||
|
||||
class ArtistDetailResponse(BaseModel):
|
||||
id: UUID
|
||||
id: str
|
||||
name: str
|
||||
works: Dict[str, List[str]]
|
||||
|
||||
def get_artist_details(artist: Artist) -> ArtistDetailResponse:
|
||||
works = {}
|
||||
for work in artist.comic_works:
|
||||
work_type = work.work_type.name
|
||||
comic_title = work.comic.title
|
||||
if work_type in works:
|
||||
works[work_type].append(comic_title)
|
||||
else:
|
||||
works[work_type] = [comic_title]
|
||||
response = ArtistDetailResponse(
|
||||
id=artist.id,
|
||||
name=artist.name,
|
||||
works=works
|
||||
)
|
||||
return response
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@ from src.db.models.comic import Comic
|
||||
|
||||
|
||||
class ComicResponse(BaseModel):
|
||||
id: UUID
|
||||
id: str
|
||||
title: str
|
||||
completed: bool
|
||||
|
||||
class ComicDetailsResponse(BaseModel):
|
||||
id: UUID
|
||||
id: str
|
||||
created: str
|
||||
title: str
|
||||
completed : bool
|
||||
|
||||
Reference in New Issue
Block a user