refactor(arch): eliminate all cross-module model imports in service layer
Some checks failed
Some checks failed
Enforce MOD-025/MOD-026 rules: zero top-level cross-module model imports remain in any service file. All 66 files migrated using deferred import patterns (method-body, _get_model() helpers, instance-cached self._Model) and new cross-module service methods in tenancy. Documentation updated with Pattern 6 (deferred imports), migration plan marked complete, and violations status reflects 84→0 service-layer violations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -115,21 +115,15 @@ class FeatureService:
|
||||
Returns:
|
||||
Tuple of (merchant_id, platform_id), either may be None
|
||||
"""
|
||||
from app.modules.tenancy.models import Store, StorePlatform
|
||||
from app.modules.tenancy.services.platform_service import platform_service
|
||||
from app.modules.tenancy.services.store_service import store_service
|
||||
|
||||
store = db.query(Store).filter(Store.id == store_id).first()
|
||||
store = store_service.get_store_by_id_optional(db, store_id)
|
||||
if not store:
|
||||
return None, None
|
||||
|
||||
merchant_id = store.merchant_id
|
||||
# Get primary platform_id from StorePlatform junction
|
||||
sp = (
|
||||
db.query(StorePlatform.platform_id)
|
||||
.filter(StorePlatform.store_id == store_id, StorePlatform.is_active == True) # noqa: E712
|
||||
.order_by(StorePlatform.is_primary.desc())
|
||||
.first()
|
||||
)
|
||||
platform_id = sp[0] if sp else None
|
||||
platform_id = platform_service.get_primary_platform_id_for_store(db, store_id)
|
||||
|
||||
return merchant_id, platform_id
|
||||
|
||||
@@ -142,19 +136,14 @@ class FeatureService:
|
||||
Returns all active platform IDs for the store's merchant,
|
||||
ordered with the primary platform first.
|
||||
"""
|
||||
from app.modules.tenancy.models import Store, StorePlatform
|
||||
from app.modules.tenancy.services.platform_service import platform_service
|
||||
from app.modules.tenancy.services.store_service import store_service
|
||||
|
||||
store = db.query(Store).filter(Store.id == store_id).first()
|
||||
store = store_service.get_store_by_id_optional(db, store_id)
|
||||
if not store:
|
||||
return None, []
|
||||
|
||||
platform_ids = [
|
||||
sp[0]
|
||||
for sp in db.query(StorePlatform.platform_id)
|
||||
.filter(StorePlatform.store_id == store_id, StorePlatform.is_active == True) # noqa: E712
|
||||
.order_by(StorePlatform.is_primary.desc())
|
||||
.all()
|
||||
]
|
||||
platform_ids = platform_service.get_active_platform_ids_for_store(db, store_id)
|
||||
return store.merchant_id, platform_ids
|
||||
|
||||
def _get_subscription(
|
||||
|
||||
Reference in New Issue
Block a user