
- 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
50 lines
1.2 KiB
Python
50 lines
1.2 KiB
Python
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
# Shared properties
|
|
class PublisherBase(BaseModel):
|
|
name: str = Field(..., min_length=1, max_length=100, description="Name of the publisher")
|
|
website: str | None = Field(None, description="Website URL of the publisher")
|
|
country: str | None = Field(None, max_length=50, description="Country of the publisher")
|
|
|
|
|
|
# Properties to receive on publisher creation
|
|
class PublisherCreate(PublisherBase):
|
|
pass
|
|
|
|
|
|
# Properties to receive on publisher update
|
|
class PublisherUpdate(PublisherBase):
|
|
name: str | None = Field(
|
|
None, min_length=1, max_length=100, description="Name of the publisher"
|
|
)
|
|
|
|
|
|
# Properties shared by models stored in DB
|
|
class PublisherInDBBase(PublisherBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
# Properties to return to client
|
|
class Publisher(PublisherInDBBase):
|
|
pass
|
|
|
|
|
|
# Properties properties stored in DB
|
|
class PublisherInDB(PublisherInDBBase):
|
|
pass
|
|
|
|
|
|
# Additional properties for response with manga list
|
|
class PublisherWithManga(Publisher):
|
|
from app.schemas.manga import Manga # Avoid circular import
|
|
|
|
manga_list: list[Manga] = []
|