
- 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)
42 lines
880 B
Python
42 lines
880 B
Python
from typing import Optional
|
|
from datetime import datetime
|
|
from pydantic import BaseModel, EmailStr
|
|
|
|
|
|
# Shared properties
|
|
class SupplierBase(BaseModel):
|
|
name: str
|
|
contact_name: Optional[str] = None
|
|
email: Optional[EmailStr] = None
|
|
phone: Optional[str] = None
|
|
address: Optional[str] = None
|
|
|
|
|
|
# Properties to receive on supplier creation
|
|
class SupplierCreate(SupplierBase):
|
|
pass
|
|
|
|
|
|
# Properties to receive on supplier update
|
|
class SupplierUpdate(SupplierBase):
|
|
name: Optional[str] = None
|
|
|
|
|
|
# Properties shared by models stored in DB
|
|
class SupplierInDBBase(SupplierBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
# Properties to return to client
|
|
class Supplier(SupplierInDBBase):
|
|
pass
|
|
|
|
|
|
# Properties properties stored in DB
|
|
class SupplierInDB(SupplierInDBBase):
|
|
pass |