- 重构sys模块架构,严格按admin/api/core分层 - 对齐所有sys实体与数据库表结构 - 实现完整的adminapi控制器,匹配PHP/Java契约 - 修复依赖注入问题,确保服务正确注册 - 添加自动迁移工具和契约验证 - 完善多租户支持和审计功能 - 统一命名规范,与PHP业务逻辑保持一致
70 lines
1.7 KiB
TypeScript
70 lines
1.7 KiB
TypeScript
import { Controller, Post, Body, Get } from '@nestjs/common';
|
|
import { TestService } from './test.service';
|
|
import { Public } from '../src/core/decorators/public.decorator';
|
|
|
|
@Controller('test')
|
|
export class TestController {
|
|
constructor(private readonly testService: TestService) {}
|
|
|
|
@Get('status')
|
|
@Public()
|
|
getStatus() {
|
|
return {
|
|
message: 'Test module is working',
|
|
timestamp: new Date().toISOString(),
|
|
services: {
|
|
redis: 'available',
|
|
kafka: 'available',
|
|
},
|
|
};
|
|
}
|
|
|
|
@Post('kafka')
|
|
@Public()
|
|
async testKafka(@Body() data: Record<string, any>) {
|
|
try {
|
|
await this.testService.publishKafkaEvent('test-topic', {
|
|
message: 'Hello from WWJCloud Test Module!',
|
|
data,
|
|
timestamp: new Date().toISOString(),
|
|
});
|
|
return {
|
|
success: true,
|
|
message: 'Event published to Kafka successfully',
|
|
topic: 'test-topic',
|
|
data,
|
|
};
|
|
} catch (error) {
|
|
return {
|
|
success: false,
|
|
message: 'Failed to publish event to Kafka',
|
|
error: error instanceof Error ? error.message : String(error),
|
|
};
|
|
}
|
|
}
|
|
|
|
@Post('redis')
|
|
@Public()
|
|
async testRedis(@Body() data: Record<string, any>) {
|
|
try {
|
|
const jobId = await this.testService.enqueueRedisJob('test-job', {
|
|
message: 'Hello from WWJCloud Test Module!',
|
|
data,
|
|
timestamp: new Date().toISOString(),
|
|
});
|
|
return {
|
|
success: true,
|
|
message: 'Job queued to Redis successfully',
|
|
jobId,
|
|
data,
|
|
};
|
|
} catch (error) {
|
|
return {
|
|
success: false,
|
|
message: 'Failed to queue job to Redis',
|
|
error: error instanceof Error ? error.message : String(error),
|
|
};
|
|
}
|
|
}
|
|
}
|