from pydantic import BaseModel
from typing import Optional
from datetime import datetime


class InspectionLocationCreate(BaseModel):
    code: str
    name: str
    description: Optional[str] = None
    sort_order: int = 0


class InspectionLocationOut(InspectionLocationCreate):
    id: int
    created_at: datetime

    class Config:
        from_attributes = True


class InspectionRecordCreate(BaseModel):
    location_id: int
    equipment_code: Optional[str] = None
    equipment_name: Optional[str] = None
    scan_code: Optional[str] = None
    inspector: str
    result: str = "normal"
    notes: Optional[str] = None


class InspectionRecordOut(InspectionRecordCreate):
    id: int
    location_name: Optional[str] = None
    created_at: datetime

    class Config:
        from_attributes = True
