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:
@@ -369,11 +369,10 @@ def get_platform_email_config(db: Session) -> dict:
|
||||
Returns:
|
||||
Dictionary with all email configuration values
|
||||
"""
|
||||
from app.modules.tenancy.models import AdminSetting
|
||||
from app.modules.core.services.admin_settings_service import admin_settings_service
|
||||
|
||||
def get_db_setting(key: str) -> str | None:
|
||||
setting = db.query(AdminSetting).filter(AdminSetting.key == key).first()
|
||||
return setting.value if setting else None
|
||||
return admin_settings_service.get_setting_value(db, key)
|
||||
|
||||
config = {}
|
||||
|
||||
@@ -999,10 +998,10 @@ class EmailService:
|
||||
def _get_store(self, store_id: int):
|
||||
"""Get store with caching."""
|
||||
if store_id not in self._store_cache:
|
||||
from app.modules.tenancy.models import Store
|
||||
from app.modules.tenancy.services.store_service import store_service
|
||||
|
||||
self._store_cache[store_id] = (
|
||||
self.db.query(Store).filter(Store.id == store_id).first()
|
||||
self._store_cache[store_id] = store_service.get_store_by_id_optional(
|
||||
self.db, store_id
|
||||
)
|
||||
return self._store_cache[store_id]
|
||||
|
||||
@@ -1121,11 +1120,9 @@ class EmailService:
|
||||
|
||||
# 2. Customer's preferred language
|
||||
if customer_id:
|
||||
from app.modules.customers.models.customer import Customer
|
||||
from app.modules.customers.services.customer_service import customer_service
|
||||
|
||||
customer = (
|
||||
self.db.query(Customer).filter(Customer.id == customer_id).first()
|
||||
)
|
||||
customer = customer_service.get_customer_by_id(self.db, customer_id)
|
||||
if customer and customer.preferred_language in SUPPORTED_LANGUAGES:
|
||||
return customer.preferred_language
|
||||
|
||||
|
||||
Reference in New Issue
Block a user