from typing import Optional from decimal import Decimal from pydantic import Field, HttpUrl from app.schemas.base import BaseSchema, TimestampSchema class ProductBase(BaseSchema): """Base schema for Product data.""" name: str description: Optional[str] = None price: Decimal = Field(..., ge=0, decimal_places=2) sku: str stock_quantity: int = Field(..., ge=0) is_active: bool = True image_url: Optional[HttpUrl] = None class ProductCreate(ProductBase): """Schema for creating a new product.""" pass class ProductUpdate(BaseSchema): """Schema for updating a product.""" name: Optional[str] = None description: Optional[str] = None price: Optional[Decimal] = Field(None, ge=0, decimal_places=2) sku: Optional[str] = None stock_quantity: Optional[int] = Field(None, ge=0) is_active: Optional[bool] = None image_url: Optional[HttpUrl] = None class ProductInDBBase(ProductBase, TimestampSchema): """Base schema for Product in DB (with ID).""" id: int class Product(ProductInDBBase): """Schema for Product response.""" pass class ProductInDB(ProductInDBBase): """Schema for Product in DB.""" pass