mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-12-01 00:08:47 +00:00
refactor: Update tenant integration to use concrete service types and tenant package imports
- Change TenantIntegrationManager.tenantService from Service interface to *services.TenantServiceImpl concrete type - Change TenantResourceQuotaChecker.tenantService from Service interface to *services.TenantServiceImpl - Change TenantEventLogger.tenantService from Service interface to *services.TenantServiceImpl - Update TenantAwareServices fields to use tenant package types (TenantContext, TenantConfig)
This commit is contained in:
@@ -6,7 +6,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/currency"
|
||||
"github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/repository"
|
||||
"github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/repository"
|
||||
"github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/services"
|
||||
"github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/tenant"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -129,14 +131,14 @@ func (r *TenantAwareCurrencyRepository) CountTransactions(ctx context.Context, f
|
||||
|
||||
// TenantIntegrationManager manages tenant integration across all services
|
||||
type TenantIntegrationManager struct {
|
||||
tenantService Service
|
||||
tenantService *services.TenantServiceImpl
|
||||
currencyService currency.BillingService
|
||||
logger *logrus.Logger
|
||||
}
|
||||
|
||||
// NewTenantIntegrationManager creates a new tenant integration manager
|
||||
func NewTenantIntegrationManager(
|
||||
tenantService Service,
|
||||
tenantService *services.TenantServiceImpl,
|
||||
currencyService currency.BillingService,
|
||||
logger *logrus.Logger,
|
||||
) *TenantIntegrationManager {
|
||||
@@ -175,8 +177,8 @@ func (m *TenantIntegrationManager) GetTenantAwareServices(ctx context.Context, t
|
||||
// TenantAwareServices provides tenant-aware service instances
|
||||
type TenantAwareServices struct {
|
||||
TenantID string
|
||||
TenantContext *TenantContext
|
||||
Config *TenantConfig
|
||||
TenantContext *tenant.TenantContext
|
||||
Config *tenant.TenantConfig
|
||||
CurrencyService currency.BillingService
|
||||
}
|
||||
|
||||
@@ -189,12 +191,12 @@ func (m *TenantIntegrationManager) wrapCurrencyService(tenantID string) currency
|
||||
|
||||
// TenantResourceQuotaChecker checks resource quotas before operations
|
||||
type TenantResourceQuotaChecker struct {
|
||||
tenantService Service
|
||||
tenantService *services.TenantServiceImpl
|
||||
logger *logrus.Logger
|
||||
}
|
||||
|
||||
// NewTenantResourceQuotaChecker creates a new quota checker
|
||||
func NewTenantResourceQuotaChecker(tenantService Service, logger *logrus.Logger) *TenantResourceQuotaChecker {
|
||||
func NewTenantResourceQuotaChecker(tenantService *services.TenantServiceImpl, logger *logrus.Logger) *TenantResourceQuotaChecker {
|
||||
return &TenantResourceQuotaChecker{
|
||||
tenantService: tenantService,
|
||||
logger: logger,
|
||||
@@ -213,12 +215,12 @@ func (c *TenantResourceQuotaChecker) UpdateUsage(ctx context.Context, tenantID,
|
||||
|
||||
// TenantEventLogger logs tenant events for audit purposes
|
||||
type TenantEventLogger struct {
|
||||
tenantService Service
|
||||
tenantService *services.TenantServiceImpl
|
||||
logger *logrus.Logger
|
||||
}
|
||||
|
||||
// NewTenantEventLogger creates a new tenant event logger
|
||||
func NewTenantEventLogger(tenantService Service, logger *logrus.Logger) *TenantEventLogger {
|
||||
func NewTenantEventLogger(tenantService *services.TenantServiceImpl, logger *logrus.Logger) *TenantEventLogger {
|
||||
return &TenantEventLogger{
|
||||
tenantService: tenantService,
|
||||
logger: logger,
|
||||
@@ -227,17 +229,17 @@ func NewTenantEventLogger(tenantService Service, logger *logrus.Logger) *TenantE
|
||||
|
||||
// LogResourceAccess logs resource access events
|
||||
func (l *TenantEventLogger) LogResourceAccess(ctx context.Context, tenantID, userID, resourceType, resourceID, action string) {
|
||||
event := &TenantEvent{
|
||||
event := &tenant.TenantEvent{
|
||||
ID: generateID(),
|
||||
TenantID: tenantID,
|
||||
UserID: userID,
|
||||
EventType: TenantEventType("resource_access"),
|
||||
EventType: tenant.TenantEventType("resource_access"),
|
||||
EventData: map[string]interface{}{
|
||||
"resource_type": resourceType,
|
||||
"resource_id": resourceID,
|
||||
"action": action,
|
||||
},
|
||||
Timestamp: getCurrentTimestamp(),
|
||||
Timestamp: time.Now(),
|
||||
}
|
||||
|
||||
if err := l.tenantService.LogTenantEvent(ctx, event); err != nil {
|
||||
@@ -247,17 +249,17 @@ func (l *TenantEventLogger) LogResourceAccess(ctx context.Context, tenantID, use
|
||||
|
||||
// LogQuotaViolation logs quota violation events
|
||||
func (l *TenantEventLogger) LogQuotaViolation(ctx context.Context, tenantID, resourceType string, usage, limit int) {
|
||||
event := &TenantEvent{
|
||||
event := &tenant.TenantEvent{
|
||||
ID: generateID(),
|
||||
TenantID: tenantID,
|
||||
UserID: "",
|
||||
EventType: TenantEventQuotaExceeded,
|
||||
EventType: tenant.TenantEventQuotaExceeded,
|
||||
EventData: map[string]interface{}{
|
||||
"resource_type": resourceType,
|
||||
"usage": usage,
|
||||
"limit": limit,
|
||||
},
|
||||
Timestamp: getCurrentTimestamp(),
|
||||
Timestamp: time.Now(),
|
||||
}
|
||||
|
||||
if err := l.tenantService.LogTenantEvent(ctx, event); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user