
- Add proper model relationships for better querying - Implement character model and endpoints for managing anime characters - Add advanced filtering options (year, score range, source, studio, etc.) - Add statistics endpoint for analyzing anime collection - Include pagination metadata for easier navigation - Create Alembic migration for the new character model - Update README with new features and documentation
49 lines
1.0 KiB
Python
49 lines
1.0 KiB
Python
from typing import Optional
|
|
from datetime import date
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class CharacterBase(BaseModel):
|
|
name: str
|
|
role: Optional[str] = None
|
|
description: Optional[str] = None
|
|
voice_actor: Optional[str] = None
|
|
image_url: Optional[str] = None
|
|
age: Optional[str] = None
|
|
gender: Optional[str] = None
|
|
birth_date: Optional[date] = None
|
|
height: Optional[str] = None
|
|
weight: Optional[str] = None
|
|
blood_type: Optional[str] = None
|
|
popularity_rank: Optional[int] = None
|
|
|
|
|
|
class CharacterCreate(CharacterBase):
|
|
anime_id: int
|
|
|
|
|
|
class CharacterUpdate(CharacterBase):
|
|
name: Optional[str] = None
|
|
anime_id: Optional[int] = None
|
|
|
|
|
|
class Character(CharacterBase):
|
|
id: int
|
|
anime_id: int
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class CharacterWithAnime(Character):
|
|
anime_title: str = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class CharacterSearchResults(BaseModel):
|
|
results: list[Character]
|
|
total: int
|
|
page: int
|
|
size: int |