dd16940bb2
- Company CRUD with soft-delete, FTS search (tsvector + GIN), filter, pagination - Contact CRUD with N:M company linking via company_contacts - CSV/XLSX export, CSV import with dry-run preview - GDPR hard-delete with deletion_log - Audit log on all mutations - 27 new tests (24 ACs), 56 total tests pass - Migration 0002: contacts, company_contacts, FTS search_tsv - Fixed T01 tests: POST→201, PATCH→PUT compatibility
56 lines
1.6 KiB
Python
56 lines
1.6 KiB
Python
"""Company schemas — create, update, read, list, pagination, search, filter."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class CompanyCreate(BaseModel):
|
|
name: str = Field(..., 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)
|
|
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)
|
|
description: str | None = None
|
|
|
|
|
|
class CompanyResponse(BaseModel):
|
|
id: str
|
|
name: str
|
|
account_number: str | None = None
|
|
industry: str | None = None
|
|
phone: str | None = None
|
|
email: str | None = None
|
|
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
|