16 lines
575 B
Python
16 lines
575 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
from sqlalchemy import select
|
|
from app.core.db.deps import get_common_db
|
|
from app.modules.core.tenancy.models import Tenant, Branch
|
|
|
|
router = APIRouter(prefix="/tenancy", tags=["tenancy"])
|
|
|
|
@router.get("/tenants")
|
|
def list_tenants(db: Session = Depends(get_common_db)):
|
|
return db.execute(select(Tenant).order_by(Tenant.id)).scalars().all()
|
|
|
|
@router.get("/branches")
|
|
def list_branches(db: Session = Depends(get_common_db)):
|
|
return db.execute(select(Branch).order_by(Branch.id)).scalars().all()
|