
- Set up project structure and FastAPI application - Create database models for users, products, and inventory - Configure SQLAlchemy and Alembic for database management - Implement JWT authentication - Create API endpoints for user, product, and inventory management - Add admin-only routes and authorization middleware - Add health check endpoint - Update README with documentation - Lint and fix code issues
74 lines
1.9 KiB
Python
74 lines
1.9 KiB
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from app.models.inventory import InventoryStatus
|
|
from app.schemas.product import Product
|
|
|
|
|
|
# Inventory item schemas
|
|
class InventoryItemBase(BaseModel):
|
|
"""Base inventory item schema."""
|
|
product_id: str
|
|
quantity: int = Field(..., ge=0)
|
|
status: InventoryStatus = InventoryStatus.OUT_OF_STOCK
|
|
location: Optional[str] = None
|
|
notes: Optional[str] = None
|
|
|
|
|
|
class InventoryItemCreate(InventoryItemBase):
|
|
"""Inventory item creation schema."""
|
|
pass
|
|
|
|
|
|
class InventoryItemUpdate(BaseModel):
|
|
"""Inventory item update schema."""
|
|
quantity: Optional[int] = Field(None, ge=0)
|
|
status: Optional[InventoryStatus] = None
|
|
location: Optional[str] = None
|
|
notes: Optional[str] = None
|
|
|
|
|
|
class InventoryItem(InventoryItemBase):
|
|
"""Inventory item schema to return to client."""
|
|
id: str
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
"""Configuration for the schema."""
|
|
from_attributes = True
|
|
|
|
|
|
class InventoryItemWithProduct(InventoryItem):
|
|
"""Inventory item schema with product to return to client."""
|
|
product: Product
|
|
|
|
class Config:
|
|
"""Configuration for the schema."""
|
|
from_attributes = True
|
|
|
|
|
|
# Inventory transaction schemas
|
|
class InventoryTransactionBase(BaseModel):
|
|
"""Base inventory transaction schema."""
|
|
product_id: str
|
|
quantity_change: int
|
|
notes: Optional[str] = None
|
|
transaction_by: Optional[str] = None
|
|
|
|
|
|
class InventoryTransactionCreate(InventoryTransactionBase):
|
|
"""Inventory transaction creation schema."""
|
|
pass
|
|
|
|
|
|
class InventoryTransaction(InventoryTransactionBase):
|
|
"""Inventory transaction schema to return to client."""
|
|
id: str
|
|
created_at: datetime
|
|
|
|
class Config:
|
|
"""Configuration for the schema."""
|
|
from_attributes = True |