
- Implemented CRUD operations for manga, authors, publishers, and genres - Added search and filtering functionality - Set up SQLAlchemy ORM with SQLite database - Configured Alembic for database migrations - Implemented logging with Loguru - Added comprehensive API documentation - Set up error handling and validation - Added ruff for linting and formatting
47 lines
1.0 KiB
Python
47 lines
1.0 KiB
Python
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
# Shared properties
|
|
class AuthorBase(BaseModel):
|
|
name: str = Field(..., min_length=1, max_length=100, description="Name of the author")
|
|
biography: str | None = Field(None, description="Author's biography")
|
|
|
|
|
|
# Properties to receive on author creation
|
|
class AuthorCreate(AuthorBase):
|
|
pass
|
|
|
|
|
|
# Properties to receive on author update
|
|
class AuthorUpdate(AuthorBase):
|
|
name: str | None = Field(None, min_length=1, max_length=100, description="Name of the author")
|
|
|
|
|
|
# Properties shared by models stored in DB
|
|
class AuthorInDBBase(AuthorBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
# Properties to return to client
|
|
class Author(AuthorInDBBase):
|
|
pass
|
|
|
|
|
|
# Properties properties stored in DB
|
|
class AuthorInDB(AuthorInDBBase):
|
|
pass
|
|
|
|
|
|
# Additional properties for response with manga list
|
|
class AuthorWithManga(Author):
|
|
from app.schemas.manga import Manga # Avoid circular import
|
|
|
|
manga_list: list[Manga] = []
|