fix: correct imports in admin subscriptions module
- Use get_current_admin_api instead of non-existent get_current_admin - Use get_db from app.core.database - Replace generic NotFoundException with specific exceptions: - TierNotFoundException for tier lookup failures - ConflictException for duplicate tier codes - BusinessLogicException for tier deletion with active subscriptions - ResourceNotFoundException for subscription lookup failures 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,12 @@ from math import ceil
|
||||
from sqlalchemy import func
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.exceptions import NotFoundException
|
||||
from app.exceptions import (
|
||||
BusinessLogicException,
|
||||
ConflictException,
|
||||
ResourceNotFoundException,
|
||||
TierNotFoundException,
|
||||
)
|
||||
from models.database.subscription import (
|
||||
BillingHistory,
|
||||
SubscriptionStatus,
|
||||
@@ -54,7 +59,7 @@ class AdminSubscriptionService:
|
||||
)
|
||||
|
||||
if not tier:
|
||||
raise NotFoundException(f"Tier '{tier_code}' not found")
|
||||
raise TierNotFoundException(tier_code)
|
||||
|
||||
return tier
|
||||
|
||||
@@ -67,7 +72,7 @@ class AdminSubscriptionService:
|
||||
.first()
|
||||
)
|
||||
if existing:
|
||||
raise NotFoundException(
|
||||
raise ConflictException(
|
||||
f"Tier with code '{tier_data['code']}' already exists"
|
||||
)
|
||||
|
||||
@@ -107,7 +112,7 @@ class AdminSubscriptionService:
|
||||
)
|
||||
|
||||
if active_subs > 0:
|
||||
raise NotFoundException(
|
||||
raise BusinessLogicException(
|
||||
f"Cannot delete tier: {active_subs} active subscriptions are using it"
|
||||
)
|
||||
|
||||
@@ -172,7 +177,7 @@ class AdminSubscriptionService:
|
||||
)
|
||||
|
||||
if not result:
|
||||
raise NotFoundException(f"Subscription for vendor {vendor_id} not found")
|
||||
raise ResourceNotFoundException(f"Subscription for vendor {vendor_id} not found")
|
||||
|
||||
return result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user