All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 1m0s
- AI: 新三层架构 Provider→Gateway→Workflow(15文件,DeepSeek+MiniMax) - Auth: 全局JwtAuthGuard + @Public()装饰器白名单路由 - DB: 12个Repository从Map/Array迁到Prisma - Schema: 新增AiUsageLog、WaitlistEntry模型 - API: /api-docs-json加Basic Auth保护 - 清理: 删除infrastructure/ai、docs/旧文档 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
28 lines
855 B
TypeScript
28 lines
855 B
TypeScript
import { Injectable, NotFoundException, Logger } from '@nestjs/common';
|
|
import { NotificationsRepository } from './notifications.repository';
|
|
|
|
@Injectable()
|
|
export class NotificationsService {
|
|
private readonly logger = new Logger(NotificationsService.name);
|
|
|
|
constructor(private readonly repository: NotificationsRepository) {}
|
|
|
|
async list(userId: string) {
|
|
return this.repository.findAll(userId);
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|