2026-06-29 00:44:34 +02:00
|
|
|
"""Company schemas — create, update, read, list, pagination, search, filter."""
|
2026-06-29 00:10:10 +02:00
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CompanyCreate(BaseModel):
|
|
|
|
|
name: str = Field(..., min_length=1, max_length=100)
|
2026-06-29 00:44:34 +02:00
|
|
|
account_number: str | None = Field(None, max_length=40)
|
|
|
|
|
industry: str | None = Field(None, max_length=50)
|
|
|
|
|
phone: str | None = Field(None, max_length=30)
|
|
|
|
|
email: str | None = Field(None, max_length=255)
|
|
|
|
|
website: str | None = Field(None, max_length=500)
|
|
|
|
|
description: str | None = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CompanyUpdate(BaseModel):
|
|
|
|
|
name: str | None = Field(None, min_length=1, max_length=100)
|
|
|
|
|
account_number: str | None = Field(None, max_length=40)
|
|
|
|
|
industry: str | None = Field(None, max_length=50)
|
|
|
|
|
phone: str | None = Field(None, max_length=30)
|
|
|
|
|
email: str | None = Field(None, max_length=255)
|
|
|
|
|
website: str | None = Field(None, max_length=500)
|
2026-06-29 00:10:10 +02:00
|
|
|
description: str | None = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CompanyResponse(BaseModel):
|
|
|
|
|
id: str
|
|
|
|
|
name: str
|
2026-06-29 00:44:34 +02:00
|
|
|
account_number: str | None = None
|
2026-06-29 00:10:10 +02:00
|
|
|
industry: str | None = None
|
|
|
|
|
phone: str | None = None
|
|
|
|
|
email: str | None = None
|
2026-06-29 00:44:34 +02:00
|
|
|
website: str | None = None
|
|
|
|
|
description: str | None = None
|
|
|
|
|
created_at: str | None = None
|
|
|
|
|
updated_at: str | None = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CompanyDetailResponse(CompanyResponse):
|
|
|
|
|
contacts: list[dict] = Field(default_factory=list)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CompanyListResponse(BaseModel):
|
|
|
|
|
items: list[CompanyResponse]
|
|
|
|
|
total: int
|
|
|
|
|
page: int
|
|
|
|
|
page_size: int
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CompanyExportRequest(BaseModel):
|
|
|
|
|
format: str = Field("csv", pattern="^(csv|xlsx)$")
|
|
|
|
|
industry: str | None = None
|
|
|
|
|
search: str | None = None
|