- 重构sys模块架构,严格按admin/api/core分层 - 对齐所有sys实体与数据库表结构 - 实现完整的adminapi控制器,匹配PHP/Java契约 - 修复依赖注入问题,确保服务正确注册 - 添加自动迁移工具和契约验证 - 完善多租户支持和审计功能 - 统一命名规范,与PHP业务逻辑保持一致
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { Injectable } from '@nestjs/common';
|
||
import { UnifiedQueueService } from '@wwjCore/queue/unifiedQueueService';
|
||
|
||
@Injectable()
|
||
export class TestService {
|
||
constructor(private readonly unifiedQueueService: UnifiedQueueService) {}
|
||
|
||
async publishKafkaEvent(
|
||
topic: string,
|
||
data: Record<string, any>,
|
||
): Promise<void> {
|
||
await this.unifiedQueueService.publishEvent({
|
||
eventType: topic,
|
||
aggregateId: 'test-aggregate',
|
||
aggregateType: 'Test',
|
||
version: '1.0',
|
||
occurredAt: new Date().toISOString(),
|
||
tenantId: '0',
|
||
idempotencyKey: `key_${Date.now()}`,
|
||
traceId: `trace_${Date.now()}`,
|
||
data,
|
||
});
|
||
}
|
||
|
||
async enqueueRedisJob(
|
||
type: string,
|
||
payload: Record<string, any>,
|
||
): Promise<string> {
|
||
await this.unifiedQueueService.addTask('test-queue', type, payload, {
|
||
attempts: 3,
|
||
backoff: { type: 'fixed', delay: 1000 },
|
||
removeOnComplete: true,
|
||
removeOnFail: false,
|
||
});
|
||
|
||
// 生成一个模拟的 job ID(测试用)
|
||
return `job_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
||
}
|
||
}
|