diff --git a/node_api/src/modules/meeting/meeting.controller.ts b/node_api/src/modules/meeting/meeting.controller.ts index 511bf1b..47fde9c 100644 --- a/node_api/src/modules/meeting/meeting.controller.ts +++ b/node_api/src/modules/meeting/meeting.controller.ts @@ -5,7 +5,7 @@ import { MeetingService } from './meeting.service'; import { NonEmptyStringPipe } from '@/common/pipes/non-empty-string.pipe'; import { Uint32Pipe } from '@/common/pipes/uint32.pipe'; import { ApiCustomOkResponse } from '@/common/decorators/swagger.decorator'; -import { SaveStudentOrderDto, StudentListResponseDto, TokenResponseDto } from './meeting.dto'; +import { SaveStudentOrderDto, StudentDetailResponseDto, TokenResponseDto } from './meeting.dto'; import { MeetingRedisService } from '../websocket/meeting-redis.service'; import { MeetingWebSocketGateway } from '../websocket/meeting.websocket'; @@ -98,16 +98,13 @@ export class MeetingController { @ApiQuery({ name: 'roomId', description: '房间 ID (可选,用于获取 Redis 中的排序)', required: false, example: 'n_1234567890' }) @ApiCustomOkResponse({ summary: '学生详细信息列表', - model: StudentListResponseDto, + model: [StudentDetailResponseDto], apiDescription: '学生详细信息列表,包含长 ID、短 ID (可能为 null) 和姓名', resDescription: '学生详细信息列表', }) public async getStudentDetails(@Query('homeworkId', ParseIntPipe) homeworkId: number, @Query('roomId', NonEmptyStringPipe) roomId?: string) { const students = await this.meetingService.getStudentDetailsByHomeworkId(homeworkId, roomId); - return new OkResult({ - total: students.length, - students, - }); + return new OkResult(students); } /** diff --git a/node_api/src/modules/meeting/meeting.dto.ts b/node_api/src/modules/meeting/meeting.dto.ts index 3000746..6dbc7d1 100644 --- a/node_api/src/modules/meeting/meeting.dto.ts +++ b/node_api/src/modules/meeting/meeting.dto.ts @@ -28,17 +28,6 @@ export class StudentDetailResponseDto { studentName!: string; } -/** - * 学生列表响应 DTO - */ -export class StudentListResponseDto { - @ApiProperty({ description: '学生总数', example: 30 }) - total!: number; - - @ApiProperty({ description: '学生列表', type: [StudentDetailResponseDto] }) - students!: StudentDetailResponseDto[]; -} - /** * 保存学生排序请求 DTO */ diff --git a/node_api/src/modules/meeting/meeting.service.ts b/node_api/src/modules/meeting/meeting.service.ts index e2c4064..f73de7e 100644 --- a/node_api/src/modules/meeting/meeting.service.ts +++ b/node_api/src/modules/meeting/meeting.service.ts @@ -54,7 +54,7 @@ export class MeetingService { INNER JOIN scs_studentgroup sg ON h.StudentGroupId = sg.Id INNER JOIN scs_studentgroupdetail sgd ON sg.Id = sgd.StudentGroupId INNER JOIN scs_user u ON sgd.StudentId = u.Id - LEFT JOIN meeting_user mu ON u.Id = mu.longUserId + LEFT JOIN meeting_user mu ON u.Id = mu.long_user_Id WHERE h.Id = ${id} `; @@ -66,18 +66,18 @@ export class MeetingService { if (missingIds.length > 0) { // 批量插入缺失的短 ID await this.em.getConnection().execute(` - INSERT INTO meeting_user (longUserId, createdAt) + INSERT INTO meeting_user (long_user_Id, created_at) VALUES ${missingIds.map((longUserId) => `(${longUserId}, NOW())`).join(',')} - ON DUPLICATE KEY UPDATE longUserId = longUserId + ON DUPLICATE KEY UPDATE long_user_Id = long_user_Id `); // 查询新分配的短 ID const newUsers = await this.em.getConnection().execute(` - SELECT longUserId, id FROM meeting_user WHERE longUserId IN (${missingIds.join(',')}) + SELECT long_user_Id, id FROM meeting_user WHERE long_user_Id IN (${missingIds.join(',')}) `); const shortIdMap = new Map(); - (newUsers as Array<{ longUserId: number; id: number }>).forEach((user) => { - shortIdMap.set(user.longUserId, user.id); + (newUsers as Array<{ long_user_Id: number; id: number }>).forEach((user) => { + shortIdMap.set(user.long_user_Id, user.id); }); // 更新缺失的短 ID