30 lines
704 B
Python
30 lines
704 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class ItemBase(BaseModel):
|
|
name: str = Field(..., min_length=1, max_length=100)
|
|
description: Optional[str] = None
|
|
price: int = Field(..., gt=0) # Price in cents
|
|
is_active: bool = True
|
|
|
|
|
|
class ItemCreate(ItemBase):
|
|
pass
|
|
|
|
|
|
class ItemUpdate(BaseModel):
|
|
name: Optional[str] = Field(None, min_length=1, max_length=100)
|
|
description: Optional[str] = None
|
|
price: Optional[int] = Field(None, gt=0)
|
|
is_active: Optional[bool] = None
|
|
|
|
|
|
class ItemResponse(ItemBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True |