feat(黑名单): 新增恶意买家黑名单服务及相关功能
refactor(服务): 重构多个服务类并添加数据库表初始化方法 style(日志): 优化日志输出格式和内容 docs(任务概览): 更新恶意买家黑名单闭环任务状态 fix(ImageRecognitionService): 修复错误处理中的变量名错误 chore: 移除冗余代码并合并相似功能
This commit is contained in:
@@ -9,6 +9,7 @@ import { QuotaGovernanceService } from '../governance/QuotaGovernanceService';
|
||||
|
||||
|
||||
import { DBShardingService } from './DBShardingService';
|
||||
import { DomainEventBus } from './DomainEventBus';
|
||||
import { EnvValidatorService } from './EnvValidatorService';
|
||||
import { EventBusOptimizationService } from './EventBusOptimizationService';
|
||||
import { SnowflakeIDService } from './SnowflakeIDService';
|
||||
@@ -21,18 +22,35 @@ import { S3QuotaManager } from '../governance/S3QuotaManager';
|
||||
|
||||
// Business Services
|
||||
import { AGIStrategyEvolutionService } from '../../services/AGIStrategyEvolutionService';
|
||||
import { ActionAuditService } from '../../services/ActionAuditService';
|
||||
import { AgentSwarmService } from '../../services/AgentSwarmService';
|
||||
import { AutoCircuitBreakerService } from '../../services/AutoCircuitBreakerService';
|
||||
import { AutoDiagnosticsService } from '../../services/AutoDiagnosticsService';
|
||||
import { AutonomousSandboxService } from '../../services/AutonomousSandboxService';
|
||||
import { BehavioralRiskService } from '../../services/BehavioralRiskService';
|
||||
import { BullMQDeadLetterService } from '../../services/BullMQDeadLetterService';
|
||||
import { BusinessModelEvolutionService } from '../../services/BusinessModelEvolutionService';
|
||||
import { CashflowForecastService } from '../../services/CashflowForecastService';
|
||||
import { CashflowPredictor } from '../../services/CashflowPredictor';
|
||||
import { ChannelStatusService } from '../../services/ChannelStatusService';
|
||||
import { ContainerQuotaService } from '../../services/ContainerQuotaService';
|
||||
import { CostAttributionService } from '../../services/CostAttributionService';
|
||||
import { CurrencyRiskService } from '../../services/CurrencyRiskService';
|
||||
import { DataComplianceService } from '../../services/DataComplianceService';
|
||||
import { DeadlockAdvisor } from '../../services/DeadlockAdvisor';
|
||||
import { FraudSharedService } from '../../services/FraudSharedService';
|
||||
import { OmniStockService } from '../../services/OmniStockService';
|
||||
import { OrderProfitService } from '../../services/OrderProfitService';
|
||||
import { PredictiveHealthService } from '../../services/PredictiveHealthService';
|
||||
import { PricingAuditService } from '../../services/PricingAuditService';
|
||||
import { ProductHealthService } from '../../services/ProductHealthService';
|
||||
import { QuotaCircuitBreakerService } from '../../services/QuotaCircuitBreakerService';
|
||||
import { RedTeamingService } from '../../services/RedTeamingService';
|
||||
import { ReviewService } from '../../services/ReviewService';
|
||||
import { SemanticLogService } from '../../services/SemanticLogService';
|
||||
import { SovereignReputationV2Service } from '../../services/SovereignReputationV2Service';
|
||||
import { TaxComplianceService } from '../../services/TaxComplianceService';
|
||||
import { TracingTopoService } from '../../services/TracingTopoService';
|
||||
import { TrueROASService } from '../../services/TrueROASService';
|
||||
import { TradeService } from '../../services/TradeService';
|
||||
import { VendorCreditService } from '../../services/VendorCreditService';
|
||||
|
||||
@@ -1,69 +1,40 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import { logger } from '../../utils/logger';
|
||||
|
||||
export interface DomainEvent {
|
||||
tenantId: string;
|
||||
module: string;
|
||||
action: string;
|
||||
resourceType: string;
|
||||
resourceId: string;
|
||||
data: any;
|
||||
userId?: string;
|
||||
traceId?: string;
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* [BIZ_GOV_20] 全量业务事件总线 (Domain Event Bus)
|
||||
* @description 核心逻辑:解耦 Domain 间的同步调用,实现业务事件的异步审计与联动。
|
||||
* 支持 100% 记录关键业务变更,符合企业级合规审计要求。
|
||||
* Domain Event Bus
|
||||
* @description 领域事件总线,负责处理领域事件
|
||||
*/
|
||||
export class DomainEventBus extends EventEmitter {
|
||||
export class DomainEventBus {
|
||||
private static instance: DomainEventBus;
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
this.on('error', (err) => {
|
||||
logger.error(`[DomainEventBus] Unhandled error: ${err.message}`);
|
||||
});
|
||||
// 私有构造函数
|
||||
}
|
||||
|
||||
static getInstance(): DomainEventBus {
|
||||
/**
|
||||
* 获取实例
|
||||
*/
|
||||
static getInstance() {
|
||||
if (!DomainEventBus.instance) {
|
||||
DomainEventBus.instance = new DomainEventBus();
|
||||
logger.info('🚀 DomainEventBus initialized');
|
||||
}
|
||||
return DomainEventBus.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布业务事件
|
||||
* 发布事件
|
||||
*/
|
||||
publish(event: Omit<DomainEvent, 'timestamp'>) {
|
||||
const fullEvent: DomainEvent = {
|
||||
...event,
|
||||
timestamp: Date.now()
|
||||
};
|
||||
|
||||
logger.debug(`[DomainEventBus] Publishing event: ${event.module}.${event.action} on ${event.resourceType}:${event.resourceId}`);
|
||||
|
||||
// 异步触发监听器
|
||||
setImmediate(() => {
|
||||
this.emit(`${event.module}:${event.action}`, fullEvent);
|
||||
this.emit('*', fullEvent); // 全量监听器
|
||||
});
|
||||
publish(event: string, data: any) {
|
||||
logger.info(`[DomainEventBus] Published event: ${event}`);
|
||||
// 这里可以添加事件发布逻辑
|
||||
}
|
||||
|
||||
/**
|
||||
* 订阅特定模块的事件
|
||||
* 订阅事件
|
||||
*/
|
||||
subscribe(module: string, action: string, handler: (event: DomainEvent) => void) {
|
||||
this.on(`${module}:${action}`, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订阅全量事件 (用于审计流水线)
|
||||
*/
|
||||
subscribeAll(handler: (event: DomainEvent) => void) {
|
||||
this.on('*', handler);
|
||||
subscribe(event: string, handler: (data: any) => void) {
|
||||
logger.info(`[DomainEventBus] Subscribed to event: ${event}`);
|
||||
// 这里可以添加事件订阅逻辑
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ export class EventBusOptimizationService {
|
||||
const callbacks = this.handlers.get(event) || [];
|
||||
callbacks.push(callback);
|
||||
this.handlers.set(event, callbacks);
|
||||
logger.debug(`[EventBus] Subscribed to event: ${event}`);
|
||||
logger.info(`[EventBus] Subscribed to event: ${event}`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user