forked from wangziqi/gongxue-base
feat: integrate notification creation into business modules (classes, schedules done; bills/occupancies/deposits need student→userId mapping)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user