feat: WWJCloud 企业级全栈框架 v0.3.5 完整更新

🚀 核心更新:
-  完善 NestJS 企业级架构设计
-  优化配置中心和基础设施层
-  增强第三方服务集成能力
-  完善多租户架构支持
- 🎯 对标 Java Spring Boot 和 PHP ThinkPHP

📦 新增文件:
- wwjcloud-nest 完整框架结构
- Docker 容器化配置
- 管理后台界面
- 数据库迁移脚本

🔑 Key: ebb38b43ec39f355f071294fd1cf9c42
This commit is contained in:
wanwu
2025-10-13 01:27:37 +08:00
parent 10bcd7f624
commit 1ed0085d15
1697 changed files with 260750 additions and 127 deletions

View File

@@ -0,0 +1,86 @@
import { Injectable, Logger } from '@nestjs/common';
import { InjectQueue } from '@nestjs/bullmq';
import { Queue } from 'bullmq';
import { BusinessException } from '@wwjCommon/exception/business.exception';
/**
* SetMemberNoJob - 基于NestJS BullMQ
* 参考: https://docs.nestjs.com/techniques/queues
* 对应 Java: @Async + RabbitMQ
* 对应 PHP: thinkqueue
*/
@Injectable()
export class SetMemberNoJob {
private readonly logger = new Logger(SetMemberNoJob.name);
constructor(@InjectQueue('member') private readonly queue: Queue) {}
/**
* 添加任务到队列 - 使用BullMQ标准API
* 参考: https://docs.nestjs.com/techniques/queues#producers
*/
async addJob(data: any, options?: any) {
try {
const job = await this.queue.add('SetMemberNo', data, options);
this.logger.log(`SetMemberNo job added to queue: ${job.id}`, data);
return job;
} catch (error) {
this.logger.error('Failed to add SetMemberNo job to queue:', error);
throw new BusinessException('SetMemberNo任务添加失败');
}
}
/**
* 处理队列任务
* 使用Core层基础设施统一队列服务、异常处理、日志服务
*/
async processJob(data: any) {
this.logger.log('SetMemberNo job processing:', data);
try {
// 任务逻辑
await this.executeJob(data);
this.logger.log('SetMemberNo job completed successfully');
} catch (error) {
this.logger.error('SetMemberNo job failed:', error);
// 使用Core层异常处理
throw new BusinessException('SetMemberNo任务处理失败', error);
}
}
/**
* 执行任务
* 使用Core层基础设施日志服务、异常处理
*/
private async executeJob(data: any) {
// 实现具体的任务逻辑
// 例如:
// - 数据清理
// - 报表生成
// - 邮件发送
// - 数据同步
// - 备份操作
this.logger.log('Executing SetMemberNo job logic with data:', data);
// 模拟异步操作
await new Promise((resolve) => setTimeout(resolve, 1000));
this.logger.log('SetMemberNo job logic completed');
}
/**
* 手动触发任务
* 使用Core层基础设施日志服务、异常处理
*/
async triggerJob(data?: any) {
this.logger.log('Manually triggering SetMemberNo job...');
try {
await this.executeJob(data || {});
} catch (error) {
this.logger.error('Failed to trigger SetMemberNo job:', error);
// 使用Core层异常处理
throw new BusinessException('SetMemberNo任务触发失败', error);
}
}
}