
- Created project structure with FastAPI framework - Set up SQLite database with SQLAlchemy ORM - Implemented models: User, Item, Supplier, Transaction - Created CRUD operations for all models - Added API endpoints for all resources - Implemented JWT authentication and authorization - Added Alembic migration scripts - Created health endpoint - Updated documentation generated with BackendIM... (backend.im)
48 lines
966 B
Python
48 lines
966 B
Python
from typing import Optional
|
|
from datetime import datetime
|
|
from pydantic import BaseModel
|
|
|
|
|
|
# Shared properties
|
|
class ItemBase(BaseModel):
|
|
name: str
|
|
description: Optional[str] = None
|
|
sku: str
|
|
quantity: int = 0
|
|
unit_price: float
|
|
category: str
|
|
location: Optional[str] = None
|
|
supplier_id: Optional[int] = None
|
|
|
|
|
|
# Properties to receive on item creation
|
|
class ItemCreate(ItemBase):
|
|
pass
|
|
|
|
|
|
# Properties to receive on item update
|
|
class ItemUpdate(ItemBase):
|
|
name: Optional[str] = None
|
|
sku: Optional[str] = None
|
|
unit_price: Optional[float] = None
|
|
category: Optional[str] = None
|
|
|
|
|
|
# Properties shared by models stored in DB
|
|
class ItemInDBBase(ItemBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
# Properties to return to client
|
|
class Item(ItemInDBBase):
|
|
pass
|
|
|
|
|
|
# Properties properties stored in DB
|
|
class ItemInDB(ItemInDBBase):
|
|
pass |