fix: repair 5 sites where StudentDingMapping.studentId was misused as User FK

- dingtalk.service.ts syncOneUser: query studentRepo (not userRepo) by mapping.studentId
- sync.service.ts importDingTalkUsers: skip User role lookup for existing mappings
- attendance.service.ts autoMatchDingRecords: use studentId directly, remove second-hop query
- schedule-sync.service.ts syncAll: skip teacher mapping block (deprecated)
- rbac.service.ts getUnboundUsers: return [] (method deleted in Task 4)
This commit is contained in:
2026-07-09 17:00:00 +08:00
parent ef1b46b9f4
commit 86f126671c
5 changed files with 14 additions and 38 deletions

View File

@@ -612,10 +612,10 @@ export class DingTalkService {
let user: User | null = null;
if (mapping) {
user = await this.userRepo.findOne({ where: { id: mapping.studentId } });
if (user) {
user.name = du.name;
await this.userRepo.save(user);
const student = await this.studentRepo.findOne({ where: { id: mapping.studentId } });
if (student) {
student.name = du.name;
await this.studentRepo.save(student);
}
await this.studentDingMappingRepo.save(mapping);
return;