
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
20 lines
693 B
Python
20 lines
693 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_multi_by_ids(
|
|
self, db: Session, *, ids: List[int], skip: int = 0, limit: int = 100
|
|
) -> List[Supplier]:
|
|
return db.query(Supplier).filter(Supplier.id.in_(ids)).offset(skip).limit(limit).all()
|
|
|
|
|
|
supplier = CRUDSupplier(Supplier) |