ifixkart-admin/Backend/app/repositories/base_repository.py
Adithiyan bbd3a3e959 feat: initial commit — full platform snapshot
- Backend: FastAPI app with all models, services, schemas, routes
- Admin Panel: Next.js dashboard with all modules
  (CRM, POS, repairs, warranties, billing, notifications, etc.)
- Ecommerce: storefront (submodule) + product catalog
- AI Agents: .agents/ skill library for Antigravity IDE
- Docs: architecture, billing, notification gateway markdown
- Submodules: Backend/OpenWA, Ecommerce/File 2/storefront
2026-10-13 12:59:47 +05:30

32 lines
933 B
Python

from typing import Generic, Type, TypeVar, List, Any, Optional
from sqlalchemy.orm import Session
from sqlalchemy import select
T = TypeVar("T")
class BaseRepository(Generic[T]):
def __init__(self, model: Type[T]):
self.model = model
def get_by_id(self, db: Session, id: Any) -> Optional[T]:
return db.get(self.model, id)
def get_all(self, db: Session, skip: int = 0, limit: int = 100) -> List[T]:
stmt = select(self.model).offset(skip).limit(limit)
return list(db.execute(stmt).scalars().all())
def create(self, db: Session, entity: T) -> T:
db.add(entity)
db.commit()
db.refresh(entity)
return entity
def update(self, db: Session, entity: T) -> T:
db.add(entity)
db.commit()
db.refresh(entity)
return entity
def delete(self, db: Session, entity: T) -> None:
db.delete(entity)
db.commit()