from typing import List, Optional from sqlalchemy.orm import Session from app.crud.base import CRUDBase from app.models.rental import Customer from app.schemas.customer import CustomerCreate, CustomerUpdate class CRUDCustomer(CRUDBase[Customer, CustomerCreate, CustomerUpdate]): """ CRUD operations for Customer model. """ def get_by_email(self, db: Session, *, email: str) -> Optional[Customer]: """ Get a customer by email. """ return db.query(Customer).filter(Customer.email == email).first() def get_by_name( self, db: Session, *, first_name: str, last_name: str, skip: int = 0, limit: int = 100 ) -> List[Customer]: """ Get customers by first and last name. """ return db.query(Customer)\ .filter(Customer.first_name == first_name, Customer.last_name == last_name)\ .offset(skip)\ .limit(limit)\ .all() customer = CRUDCustomer(Customer)