feat: Phase 1-3 全部完成 — 沙盒增强、学情分析、学习路径
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { Controller, Get, Patch, Param, Query, Req, UseGuards } from '@nestjs/common';
|
||||
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import { NotificationService } from './notification.service';
|
||||
|
||||
@ApiTags('通知')
|
||||
@Controller('notifications')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@ApiBearerAuth()
|
||||
export class NotificationController {
|
||||
constructor(private notificationService: NotificationService) {}
|
||||
|
||||
@Get()
|
||||
async findAll(@Req() req: any, @Query('page') page?: string, @Query('pageSize') pageSize?: string) {
|
||||
return this.notificationService.findAll(req.user.userId, page ? parseInt(page) : 1, pageSize ? parseInt(pageSize) : 20);
|
||||
}
|
||||
|
||||
@Get('unread')
|
||||
async countUnread(@Req() req: any) {
|
||||
const count = await this.notificationService.countUnread(req.user.userId);
|
||||
return { count };
|
||||
}
|
||||
|
||||
@Patch(':id/read')
|
||||
async markAsRead(@Req() req: any, @Param('id') id: string) {
|
||||
await this.notificationService.markAsRead(parseInt(id), req.user.userId);
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
@Patch('read-all')
|
||||
async markAllAsRead(@Req() req: any) {
|
||||
await this.notificationService.markAllAsRead(req.user.userId);
|
||||
return { ok: true };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user