Automated Action 700da98f88 Implement small business inventory management system with FastAPI and SQLite
- Created complete RESTful API for inventory management
- Set up database models for items, categories, suppliers, and transactions
- Implemented user authentication with JWT tokens
- Added transaction tracking for inventory movements
- Created comprehensive API endpoints for all CRUD operations
- Set up Alembic for database migrations
- Added input validation and error handling
- Created detailed documentation in README
2025-06-08 10:00:50 +00:00

28 lines
857 B
Python

import uuid
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 create(self, db: Session, *, obj_in: SupplierCreate) -> Supplier:
db_obj = Supplier(
id=str(uuid.uuid4()),
name=obj_in.name,
contact_name=obj_in.contact_name,
email=obj_in.email,
phone=obj_in.phone,
address=obj_in.address,
)
db.add(db_obj)
db.commit()
db.refresh(db_obj)
return db_obj
def get_by_name(self, db: Session, *, name: str) -> Supplier:
return db.query(Supplier).filter(Supplier.name == name).first()
supplier = CRUDSupplier(Supplier)