- 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>
29 lines
964 B
TypeScript
29 lines
964 B
TypeScript
import { Injectable, NotFoundException, Logger } from '@nestjs/common';
|
|
import { NotificationsRepository } from './notifications.repository';
|
|
import type { PaginationDto } from '../../common/dto/pagination.dto';
|
|
|
|
@Injectable()
|
|
export class NotificationsService {
|
|
private readonly logger = new Logger(NotificationsService.name);
|
|
|
|
constructor(private readonly repository: NotificationsRepository) {}
|
|
|
|
async list(userId: string, pagination: PaginationDto) {
|
|
return this.repository.findAll(userId, pagination);
|
|
}
|
|
|
|
async markRead(id: string) {
|
|
try {
|
|
return await this.repository.markRead(id);
|
|
} catch {
|
|
throw new NotFoundException(`Notification ${id} not found`);
|
|
}
|
|
}
|
|
|
|
async send(data: { userId: string; type: string; title: string; body: string }) {
|
|
const notification = await this.repository.create(data);
|
|
this.logger.log(`Notification ${notification.id} sent to user ${data.userId}`);
|
|
return notification;
|
|
}
|
|
}
|