feat: integrate notification creation into business modules (classes, schedules done; bills/occupancies/deposits need student→userId mapping)

This commit is contained in:
2026-07-05 23:25:34 +08:00
parent 155e3b3c96
commit 7020e86809
10 changed files with 118 additions and 30 deletions

View File

@@ -24,6 +24,8 @@ import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
import { OperationLogsService } from '../operation-logs/operation-logs.service';
import { extractRequestInfo } from '../common/request-utils';
import { RequirePermission } from '../auth/decorators/permission.decorator';
import { NotificationsService } from '../notifications/notifications.service';
import { NotificationType } from '../entities/notification.entity';
import * as ExcelJS from 'exceljs';
@UseGuards(JwtAuthGuard)
@@ -32,6 +34,7 @@ export class ClassesController {
constructor(
private readonly service: ClassesService,
private readonly logService: OperationLogsService,
private readonly notificationsService: NotificationsService,
) {}
@Get()
@@ -170,6 +173,17 @@ export class ClassesController {
ipAddress,
userAgent,
});
try {
const cls = await this.service.findOne(+id);
if (cls.headTeacherId) {
void this.notificationsService.create({
recipientIds: [cls.headTeacherId],
type: NotificationType.CLASS_CHANGE,
title: '学员变动',
content: `班级新增${result.added}名学生`,
});
}
} catch {}
return result;
}
@@ -222,6 +236,14 @@ export class ClassesController {
ipAddress,
userAgent,
});
try {
void this.notificationsService.create({
recipientIds: [dto.userId],
type: NotificationType.CLASS_CHANGE,
title: '班级分配',
content: `您已被分配到班级担任${dto.roleType}角色`,
});
} catch {}
return result;
}