52 lines
1.2 KiB
Python
52 lines
1.2 KiB
Python
from datetime import datetime
|
|
from typing import TYPE_CHECKING
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
if TYPE_CHECKING:
|
|
from app.schemas.manga import Manga
|
|
|
|
|
|
# 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):
|
|
manga_list: list["Manga"] = []
|