2026-01-17 14:18:00 +05:30
|
|
|
from sqlalchemy.orm import Session
|
|
|
|
|
from app.schemas.auth.tenant_schema import TenantCreate, TenantUpdate
|
|
|
|
|
from app.services.auth.tenant_service import TenantService
|
|
|
|
|
import uuid
|
2026-04-17 10:34:51 +05:30
|
|
|
from typing import List, Optional
|
2026-01-17 14:18:00 +05:30
|
|
|
|
|
|
|
|
class TenantController:
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
2026-08-31 20:04:12 -04:00
|
|
|
def create_tenant(db: Session, tenant_data: TenantCreate, actor=None):
|
|
|
|
|
return TenantService.create_tenant(db, tenant_data, actor=actor)
|
2026-01-17 14:18:00 +05:30
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def get_all_tenants(db: Session):
|
|
|
|
|
return TenantService.get_all_tenants(db)
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def get_tenant_by_id(db: Session, tenant_id: uuid.UUID):
|
|
|
|
|
return TenantService.get_tenant_by_id(db, tenant_id)
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
2026-08-31 20:04:12 -04:00
|
|
|
def update_tenant(db: Session, tenant_id: uuid.UUID, tenant_data: TenantUpdate, actor=None):
|
|
|
|
|
return TenantService.update_tenant(db, tenant_id, tenant_data, actor=actor)
|
2026-01-17 14:18:00 +05:30
|
|
|
|
2026-08-31 20:04:12 -04:00
|
|
|
@staticmethod
|
|
|
|
|
def subscription_history(db: Session, tenant_id: uuid.UUID, limit: int = 50):
|
|
|
|
|
from app.services.auth import subscription_history as history
|
|
|
|
|
|
|
|
|
|
return history.history_for(db, tenant_id, limit=limit)
|
|
|
|
|
|
2026-01-17 14:18:00 +05:30
|
|
|
@staticmethod
|
|
|
|
|
def delete_tenant(db: Session, tenant_id: uuid.UUID):
|
|
|
|
|
return TenantService.delete_tenant(db, tenant_id)
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def get_tenants_paginated(
|
|
|
|
|
db: Session,
|
|
|
|
|
page: int,
|
|
|
|
|
page_size: int,
|
|
|
|
|
search: Optional[str],
|
|
|
|
|
is_active: Optional[bool],
|
2026-04-17 10:34:51 +05:30
|
|
|
filter_tenant_names: Optional[List[str]] = None,
|
|
|
|
|
filter_tenant_domains: Optional[List[str]] = None,
|
|
|
|
|
filter_plan_ids: Optional[List[uuid.UUID]] = None,
|
|
|
|
|
statuses: Optional[List[bool]] = None,
|
|
|
|
|
sort_by: Optional[str] = None,
|
|
|
|
|
sort_order: Optional[str] = None,
|
2026-01-17 14:18:00 +05:30
|
|
|
):
|
|
|
|
|
return TenantService.get_tenants_paginated(
|
|
|
|
|
db=db,
|
|
|
|
|
page=page,
|
|
|
|
|
page_size=page_size,
|
|
|
|
|
search=search,
|
|
|
|
|
is_active=is_active,
|
2026-04-17 10:34:51 +05:30
|
|
|
filter_tenant_names=filter_tenant_names,
|
|
|
|
|
filter_tenant_domains=filter_tenant_domains,
|
|
|
|
|
filter_plan_ids=filter_plan_ids,
|
|
|
|
|
statuses=statuses,
|
|
|
|
|
sort_by=sort_by,
|
|
|
|
|
sort_order=sort_order,
|
2026-01-17 14:18:00 +05:30
|
|
|
)
|