Add user delete process 2
This commit is contained in:
@@ -1,11 +1,23 @@
|
||||
# services/production/app/api/production_orders_operations.py
|
||||
"""
|
||||
Tenant Data Deletion Operations (Internal Service Only)
|
||||
"""
|
||||
|
||||
# ============================================================================
|
||||
# Tenant Data Deletion Operations (Internal Service Only)
|
||||
# ============================================================================
|
||||
from fastapi import APIRouter, Depends, HTTPException, Path
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
import structlog
|
||||
|
||||
from shared.auth.decorators import get_current_user_dep
|
||||
from shared.auth.access_control import service_only_access
|
||||
from shared.routing import RouteBuilder
|
||||
from shared.services.tenant_deletion import TenantDataDeletionResult
|
||||
from app.core.database import get_db
|
||||
from app.services.tenant_deletion_service import ProductionTenantDeletionService
|
||||
|
||||
logger = structlog.get_logger()
|
||||
route_builder = RouteBuilder('production')
|
||||
router = APIRouter(tags=["production-tenant-deletion"])
|
||||
|
||||
|
||||
@router.delete(
|
||||
route_builder.build_base_route("tenant/{tenant_id}", include_tenant_prefix=False),
|
||||
@@ -60,7 +72,10 @@ async def preview_tenant_data_deletion(
|
||||
logger.info("production.tenant_deletion.preview_called", tenant_id=tenant_id)
|
||||
|
||||
deletion_service = ProductionTenantDeletionService(db)
|
||||
result = await deletion_service.preview_deletion(tenant_id)
|
||||
preview_data = await deletion_service.get_tenant_data_preview(tenant_id)
|
||||
result = TenantDataDeletionResult(tenant_id=tenant_id, service_name=deletion_service.service_name)
|
||||
result.deleted_counts = preview_data
|
||||
result.success = True
|
||||
|
||||
if not result.success:
|
||||
raise HTTPException(
|
||||
|
||||
@@ -24,7 +24,8 @@ from app.api import (
|
||||
quality_templates,
|
||||
equipment,
|
||||
internal_demo,
|
||||
orchestrator # NEW: Orchestrator integration endpoint
|
||||
orchestrator, # NEW: Orchestrator integration endpoint
|
||||
production_orders_operations # Tenant deletion endpoints
|
||||
)
|
||||
|
||||
|
||||
@@ -151,6 +152,7 @@ service.setup_custom_middleware()
|
||||
# Include standardized routers
|
||||
# NOTE: Register more specific routes before generic parameterized routes
|
||||
service.add_router(orchestrator.router) # NEW: Orchestrator integration endpoint
|
||||
service.add_router(production_orders_operations.router) # Tenant deletion endpoints
|
||||
service.add_router(quality_templates.router) # Register first to avoid route conflicts
|
||||
service.add_router(equipment.router)
|
||||
service.add_router(production_batches.router)
|
||||
|
||||
Reference in New Issue
Block a user