fix: F12 P2 follow-up — batch imports set departmentId, optimize getDescendantIds, enforce campus root invariant

This commit is contained in:
2026-07-06 01:06:11 +08:00
parent 6b0a21d266
commit 3bcb7d41c0
7 changed files with 36 additions and 11 deletions

View File

@@ -284,7 +284,8 @@ export class StudentsController {
}
}
}
const result = await this.service.batchImport(rows);
const departmentId = req.headers?.['x-campus-id'] ? parseInt(String(req.headers['x-campus-id']), 10) || undefined : undefined;
const result = await this.service.batchImport(rows, departmentId);
await this.logService.log({
userId: req.user?.id,
username: req.user?.username,

View File

@@ -115,6 +115,7 @@ export class StudentsService {
supervisor?: string;
tenantId?: number;
}[],
departmentId?: number,
) {
let imported = 0;
let skipped = 0;
@@ -140,6 +141,7 @@ export class StudentsService {
organization: row.organization || undefined,
supervisor: row.supervisor || undefined,
tenantId: row.tenantId || undefined,
departmentId: departmentId ?? undefined,
}),
);
imported++;