diff --git a/apps/server/src/students/dto/student.dto.spec.ts b/apps/server/src/students/dto/student.dto.spec.ts new file mode 100644 index 0000000..916514d --- /dev/null +++ b/apps/server/src/students/dto/student.dto.spec.ts @@ -0,0 +1,18 @@ +import 'reflect-metadata'; +import { validate } from 'class-validator'; +import { CreateStudentDto } from './student.dto'; + +describe('CreateStudentDto relationship boundaries', () => { + it('removes classId because class membership is managed by the classes API', async () => { + const dto = Object.assign(new CreateStudentDto(), { + name: '测试学生', + organizationId: 1, + classId: 9, + }); + + await validate(dto, { whitelist: true }); + + expect(dto).toMatchObject({ name: '测试学生', organizationId: 1 }); + expect(dto).not.toHaveProperty('classId'); + }); +}); diff --git a/apps/server/src/students/dto/student.dto.ts b/apps/server/src/students/dto/student.dto.ts index 40c4bdd..bc08e95 100644 --- a/apps/server/src/students/dto/student.dto.ts +++ b/apps/server/src/students/dto/student.dto.ts @@ -38,9 +38,6 @@ export class CreateStudentDto { @IsOptional() @IsString() supervisor?: string; - @IsOptional() - @IsInt() - classId?: number; } export class UpdateStudentDto {