feat(meeting): 添加通过作业ID查询学生详细信息功能

- 在MeetingController中新增getStudentDetails方法,支持通过作业ID查询学生信息
- 添加StudentDetailResponseDto和StudentListResponseDto数据传输对象
- 实现getStudentDetailsByHomeworkId服务方法,支持长短ID映射和自动分配
- 优化SQL查询逻辑,支持批量插入缺失的短ID
- 添加相应的API文档注解和参数验证
This commit is contained in:
2026-03-14 14:52:18 +08:00
parent b04877be8d
commit ff6dde5f4d
3 changed files with 160 additions and 3 deletions

View File

@ -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 { TokenResponseDto } from './meeting.dto';
import { StudentListResponseDto, TokenResponseDto } from './meeting.dto';
import { MeetingRedisService } from '../websocket/meeting-redis.service';
/**
@ -70,7 +70,7 @@ export class MeetingController {
}
/**
* 从房间黑名单移除指定用户短 UID
* 从房间黑名单移除指定用户 (短 UID)
*/
@Delete('blacklist/:roomId/:shortUid')
@HttpCode(HttpStatus.OK)
@ -89,4 +89,24 @@ export class MeetingController {
await this.redis.removeFromBlacklist(roomId, shortUid);
return new OkResult(true);
}
/**
* 通过作业 ID 查询学生详细信息列表
*/
@Get('students/:homeworkId')
@HttpCode(HttpStatus.OK)
@ApiParam({ name: 'homeworkId', description: '作业 ID', example: '1234567890' })
@ApiCustomOkResponse({
summary: '学生详细信息列表',
model: StudentListResponseDto,
apiDescription: '学生详细信息列表,包含长 ID、短 ID (可能为 null) 和姓名',
resDescription: '学生详细信息列表',
})
public async getStudentDetails(@Param('homeworkId', new Uint32Pipe('homeworkId')) homeworkId: number) {
const students = await this.meetingService.getStudentDetailsByHomeworkId(homeworkId);
return new OkResult({
total: students.length,
students,
});
}
}