
- Set up project structure with FastAPI and SQLite - Create database models for inventory management - Set up SQLAlchemy and Alembic for database migrations - Create initial database migrations - Implement CRUD operations for products, categories, suppliers - Implement stock movement tracking and inventory management - Add authentication and user management - Add API endpoints for all entities - Add health check endpoint - Update README with project information and usage instructions
24 lines
967 B
Python
24 lines
967 B
Python
from typing import List, 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]):
|
|
def get_by_name(self, db: Session, *, name: str) -> Optional[Supplier]:
|
|
return db.query(Supplier).filter(Supplier.name == name).first()
|
|
|
|
def get_by_email(self, db: Session, *, email: str) -> Optional[Supplier]:
|
|
return db.query(Supplier).filter(Supplier.email == email).first()
|
|
|
|
def search(self, db: Session, *, query: str, skip: int = 0, limit: int = 100) -> List[Supplier]:
|
|
return db.query(Supplier).filter(
|
|
Supplier.name.ilike(f"%{query}%") |
|
|
Supplier.contact_name.ilike(f"%{query}%") |
|
|
Supplier.email.ilike(f"%{query}%")
|
|
).offset(skip).limit(limit).all()
|
|
|
|
|
|
supplier = CRUDSupplier(Supplier) |