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

@@ -275,7 +275,8 @@ export class RoomsController {
monthlyRate,
});
});
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

@@ -246,6 +246,7 @@ export class RoomsService {
rentalCategory?: string;
monthlyRate?: number;
}[],
departmentId?: number,
) {
let imported = 0;
let skipped = 0;
@@ -270,6 +271,7 @@ export class RoomsService {
roomType: row.roomType || parsed.roomType || undefined,
rentalCategory: row.rentalCategory || undefined,
monthlyRate: row.monthlyRate ?? undefined,
departmentId: departmentId ?? undefined,
}),
);
imported++;