
- Create project structure with FastAPI and SQLAlchemy - Implement database models for items, categories, suppliers, and stock movements - Add CRUD operations for all models - Configure Alembic for database migrations - Create RESTful API endpoints for inventory management - Add health endpoint for system monitoring - Update README with setup and usage instructions generated with BackendIM... (backend.im)
38 lines
937 B
Python
38 lines
937 B
Python
from pydantic import BaseModel
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
|
|
class ItemBase(BaseModel):
|
|
name: str
|
|
sku: str
|
|
description: Optional[str] = None
|
|
unit_price: float
|
|
quantity: int = 0
|
|
reorder_level: int = 0
|
|
category_id: Optional[int] = None
|
|
supplier_id: Optional[int] = None
|
|
|
|
class ItemCreate(ItemBase):
|
|
pass
|
|
|
|
class ItemUpdate(BaseModel):
|
|
name: Optional[str] = None
|
|
description: Optional[str] = None
|
|
unit_price: Optional[float] = None
|
|
reorder_level: Optional[int] = None
|
|
category_id: Optional[int] = None
|
|
supplier_id: Optional[int] = None
|
|
is_active: Optional[bool] = None
|
|
|
|
class ItemResponse(ItemBase):
|
|
id: int
|
|
is_active: bool
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
class ItemDetailResponse(ItemResponse):
|
|
category: Optional[dict] = None
|
|
supplier: Optional[dict] = None |