
This commit includes: - Project structure setup with FastAPI and SQLite - Database models and schemas for inventory management - CRUD operations for all entities - API endpoints for product, category, supplier, and inventory management - User authentication with JWT tokens - Initial database migration - Comprehensive README with setup instructions
47 lines
977 B
Python
47 lines
977 B
Python
from typing import Optional
|
|
from pydantic import BaseModel
|
|
|
|
|
|
# Shared properties
|
|
class ProductBase(BaseModel):
|
|
name: Optional[str] = None
|
|
description: Optional[str] = None
|
|
sku: Optional[str] = None
|
|
barcode: Optional[str] = None
|
|
price: Optional[float] = 0.0
|
|
cost: Optional[float] = 0.0
|
|
min_stock_level: Optional[int] = 0
|
|
is_active: Optional[bool] = True
|
|
category_id: Optional[int] = None
|
|
supplier_id: Optional[int] = None
|
|
|
|
|
|
# Properties to receive on product creation
|
|
class ProductCreate(ProductBase):
|
|
name: str
|
|
sku: str
|
|
|
|
|
|
# Properties to receive on product update
|
|
class ProductUpdate(ProductBase):
|
|
pass
|
|
|
|
|
|
# Properties shared by models in DB
|
|
class ProductInDBBase(ProductBase):
|
|
id: int
|
|
name: str
|
|
sku: str
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Properties to return to client
|
|
class Product(ProductInDBBase):
|
|
pass
|
|
|
|
|
|
# Properties properties stored in DB
|
|
class ProductInDB(ProductInDBBase):
|
|
pass |