- AppModule 注册 3 个 BullMQ Workers (AiAnalysis/DocumentImport/Notification) - Users 模块新增 GET/PATCH /users/me/profile 端点: - GET 读取 UserProfile (learningIdentity, learningDirection, bio, currentGoal) - PATCH upsert UserProfile - GET /users/me 返回 profile + preferences (include join) - 新增 RolesGuard + @Roles() 装饰器 (UserRole enum) - QueueModule/QueueService 改进 - 各模块 controller/repository/service 完善 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
23 lines
817 B
TypeScript
23 lines
817 B
TypeScript
import { Processor, WorkerHost } from '@nestjs/bullmq';
|
|
import { Logger } from '@nestjs/common';
|
|
import { Job } from 'bullmq';
|
|
import { QUEUE_NOTIFICATION } from '../infrastructure/queue/queue.service';
|
|
import { NotificationsService } from '../modules/notifications/notifications.service';
|
|
|
|
@Processor(QUEUE_NOTIFICATION)
|
|
export class NotificationWorker extends WorkerHost {
|
|
private readonly logger = new Logger(NotificationWorker.name);
|
|
|
|
constructor(
|
|
private readonly notificationsService: NotificationsService,
|
|
) {
|
|
super();
|
|
}
|
|
|
|
async process(job: Job<{ userId: string; type: string; title: string; body: string }>) {
|
|
this.logger.log(`Processing notification job ${job.id}`);
|
|
await this.notificationsService.send(job.data);
|
|
this.logger.log(`Notification job ${job.id} completed`);
|
|
}
|
|
}
|