
- Created FastAPI application with SQLite database - Implemented models for inventory items, categories, suppliers, and transactions - Added authentication system with JWT tokens - Implemented CRUD operations for all models - Set up Alembic for database migrations - Added comprehensive API documentation - Configured Ruff for code linting
27 lines
788 B
Python
27 lines
788 B
Python
from typing import Optional
|
|
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.crud.base import CRUDBase
|
|
from app.models.supplier import Supplier
|
|
from app.schemas.supplier import SupplierCreate, SupplierUpdate
|
|
|
|
|
|
class CRUDSupplier(CRUDBase[Supplier, SupplierCreate, SupplierUpdate]):
|
|
"""
|
|
CRUD operations for Supplier model.
|
|
"""
|
|
def get_by_name(self, db: Session, *, name: str) -> Optional[Supplier]:
|
|
"""
|
|
Get a supplier by name.
|
|
"""
|
|
return db.query(Supplier).filter(Supplier.name == name).first()
|
|
|
|
def get_by_email(self, db: Session, *, email: str) -> Optional[Supplier]:
|
|
"""
|
|
Get a supplier by email.
|
|
"""
|
|
return db.query(Supplier).filter(Supplier.email == email).first()
|
|
|
|
|
|
supplier = CRUDSupplier(Supplier) |