ifixkart-admin/Backend/app/repositories/geo_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

35 lines
1.6 KiB
Python

from typing import Optional, List
from sqlalchemy.orm import Session
from sqlalchemy import select
from app.models.GeoModel import Country, State, City
from app.repositories.base_repository import BaseRepository
class GeographicRepository:
def get_countries(self, db: Session, active_only: bool = True) -> List[Country]:
stmt = select(Country).where(Country.deleted_at.is_(None))
if active_only:
stmt = stmt.where(Country.is_active.is_(True))
return list(db.execute(stmt).scalars().all())
def get_country_by_id(self, db: Session, country_id: int) -> Optional[Country]:
return db.get(Country, country_id)
def get_states_by_country(self, db: Session, country_id: int, active_only: bool = True) -> List[State]:
stmt = select(State).where(State.country_id == country_id, State.deleted_at.is_(None))
if active_only:
stmt = stmt.where(State.is_active.is_(True))
return list(db.execute(stmt).scalars().all())
def get_state_by_id(self, db: Session, state_id: int) -> Optional[State]:
return db.get(State, state_id)
def get_cities_by_state(self, db: Session, state_id: int, active_only: bool = True) -> List[City]:
stmt = select(City).where(City.state_id == state_id, City.deleted_at.is_(None))
if active_only:
stmt = stmt.where(City.is_active.is_(True))
return list(db.execute(stmt).scalars().all())
def get_city_by_id(self, db: Session, city_id: int) -> Optional[City]:
return db.get(City, city_id)
geo_repository = GeographicRepository()