from pydantic import BaseModel, Field
from typing import List, Optional
from ..common.base import BaseResponseWithID


class SupplierDetailResponse(BaseResponseWithID):
    """
    供应商详情模型
    """
    id: str = Field(..., description="供应商ID", examples=["company:001"])
    name: str = Field(..., description="供应商名称", examples=["腾讯集团"])
    short_name: str = Field(..., description="供应商简称", examples=["腾讯"])
    code: str = Field(..., description="供应商编码", examples=["TX001"])
    company_type: str = Field(..., description="供应商类型", examples=["other"])
    parent_id: Optional[str] = Field(None, description="上级供应商ID", examples=[None])
    path: List[str] = Field(..., description="供应商所处路径", examples=[["company:001"]])
    status: str = Field(..., description="供应商状态", examples=["active"])
    sort: int = Field(..., description="排序", examples=[1])
    credit_code: Optional[str] = Field(None, description="信用代码", examples=["914403007109310121"])
    created_by: str = Field(..., description="创建者ID", examples=["user:001"])
    created_by_name: str = Field(..., description="创建者名称", examples=["张三"])
    created_at: str = Field(..., description="创建时间", examples=["2023-10-01T12:00:00Z"])
    updated_by: str = Field(..., description="更新者ID", examples=["user:001"])
    updated_by_name: str = Field(..., description="更新者名称", examples=["张三"])
    updated_at: str = Field(..., description="更新时间", examples=["2023-10-01T12:00:00Z"])
    province: Optional[str] = Field(None, description="省份编码", examples=[None])
    city: Optional[str] = Field(None, description="城市编码", examples=[None])
    company_nature: List[Optional[str]] = Field(None, description="供应商性质数组", examples=[['supplier']])
    city_name: Optional[str] = Field(None, description="城市名称", examples=[None])
    province_name: Optional[str] = Field(None, description="省份名称", examples=[None])
    region_path: Optional[list] = Field(default_factory=list, description="供应商国家城市地址编码列表")
    country: Optional[str] = Field(None, description="国家编码", examples=[None])
    country_name: Optional[str] = Field(None, description="国家名称", examples=[None])


class SupplierListResponse(BaseModel):
    """
    供应商list
    """
    page: int
    page_size: int
    total: int
    list: List[SupplierDetailResponse] = []
