- 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>
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { PrismaService } from '../../infrastructure/database/prisma.service';
|
|
|
|
@Injectable()
|
|
export class NotificationsRepository {
|
|
constructor(private readonly prisma: PrismaService) {}
|
|
|
|
async findAll(userId: string, pagination?: { page?: number; limit?: number }) {
|
|
const page = pagination?.page ?? 1;
|
|
const limit = pagination?.limit ?? 20;
|
|
return this.prisma.notification.findMany({
|
|
where: { userId },
|
|
orderBy: { createdAt: 'desc' },
|
|
skip: (page - 1) * limit,
|
|
take: limit,
|
|
});
|
|
}
|
|
|
|
async create(data: { userId: string; type: string; title: string; body: string }) {
|
|
return this.prisma.notification.create({
|
|
data: {
|
|
userId: data.userId,
|
|
type: data.type,
|
|
title: data.title,
|
|
content: data.body,
|
|
},
|
|
});
|
|
}
|
|
|
|
async findById(id: string) {
|
|
return this.prisma.notification.findUnique({ where: { id } });
|
|
}
|
|
|
|
async markRead(id: string) {
|
|
return this.prisma.notification.update({
|
|
where: { id },
|
|
data: { readAt: new Date() },
|
|
});
|
|
}
|
|
}
|