41 lines
830 B
Python
41 lines
830 B
Python
from pydantic import BaseModel
|
|
from typing import Optional, List
|
|
from datetime import datetime
|
|
|
|
# --- Items ---
|
|
class ItemBase(BaseModel):
|
|
name: str
|
|
category: str
|
|
barcode: str
|
|
quantity: float = 0.0
|
|
min_quantity: float = 1.0
|
|
image_url: Optional[str] = None
|
|
labels_data: Optional[str] = None
|
|
|
|
class ItemCreate(ItemBase):
|
|
pass
|
|
|
|
class Item(ItemBase):
|
|
id: int
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
# --- Operations (Check-in/Check-out Validation) ---
|
|
class OperationCreate(BaseModel):
|
|
barcode: str
|
|
quantity: float
|
|
user_id: int
|
|
|
|
# --- Audit Logs ---
|
|
class AuditLogResponse(BaseModel):
|
|
id: int
|
|
timestamp: datetime
|
|
user_id: int
|
|
action: str
|
|
target_item_id: Optional[int]
|
|
quantity_change: Optional[float]
|
|
|
|
class Config:
|
|
from_attributes = True
|