Files
wwjcloud-nest-v1/wwjcloud/test/test.service.ts
万物街 127a4db1e3 feat: 完成sys模块迁移,对齐PHP/Java框架
- 重构sys模块架构,严格按admin/api/core分层
- 对齐所有sys实体与数据库表结构
- 实现完整的adminapi控制器,匹配PHP/Java契约
- 修复依赖注入问题,确保服务正确注册
- 添加自动迁移工具和契约验证
- 完善多租户支持和审计功能
- 统一命名规范,与PHP业务逻辑保持一致
2025-09-21 21:29:28 +08:00

40 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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)}`;
}
}