fix: refactor notification display logic and add format function

This commit is contained in:
xyx
2026-07-13 14:52:03 +08:00
parent 6d42241918
commit 910a4263f6
4 changed files with 39 additions and 16 deletions

View File

@@ -29,6 +29,7 @@ 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 { TeacherRoleType } from '../entities';
import * as ExcelJS from 'exceljs';
import { AuthorizationService, CaslAction, SubjectName, AuthenticatedUser } from '../authorization';
@@ -36,6 +37,13 @@ interface AuthenticatedRequest {
user: AuthenticatedUser;
}
const teacherRoleLabels: Record<string, string> = {
[TeacherRoleType.SUBJECT_TEACHER]: '任课老师',
[TeacherRoleType.HEAD_TEACHER]: '班主任',
[TeacherRoleType.LIFE_TEACHER]: '生活老师',
[TeacherRoleType.ACADEMIC_TEACHER]: '学服老师',
};
@UseGuards(JwtAuthGuard)
@Controller('classes')
export class ClassesController {
@@ -302,7 +310,7 @@ export class ClassesController {
recipientIds: [dto.userId],
type: NotificationType.CLASS_CHANGE,
title: '班级分配',
content: `您已被分配到班级担任${dto.roleType}角色`,
content: `您已被分配到班级担任${teacherRoleLabels[dto.roleType] ?? dto.roleType}角色`,
});
} catch {}
return result;