fix(sync): remove unused classStudentRepo injection, use transactional manager for class lookup

This commit is contained in:
2026-07-09 12:37:49 +08:00
parent 00de6cbd3a
commit 0f3fec6b44
2 changed files with 1 additions and 5 deletions

View File

@@ -14,7 +14,6 @@ import {
Student, Student,
Role, Role,
Class, Class,
ClassStudent,
} from '../entities'; } from '../entities';
import { SyncService } from './sync.service'; import { SyncService } from './sync.service';
import { SyncController } from './sync.controller'; import { SyncController } from './sync.controller';
@@ -34,7 +33,6 @@ import { ScheduleSyncService } from './schedule-sync.service';
Student, Student,
Role, Role,
Class, Class,
ClassStudent,
]), ]),
IntegrationModule, IntegrationModule,
AttendanceModule, AttendanceModule,

View File

@@ -40,8 +40,6 @@ export class SyncService {
private readonly roleRepo: Repository<Role>, private readonly roleRepo: Repository<Role>,
@InjectRepository(ClassEntity) @InjectRepository(ClassEntity)
private readonly classRepo: Repository<ClassEntity>, private readonly classRepo: Repository<ClassEntity>,
@InjectRepository(ClassStudent)
private readonly classStudentRepo: Repository<ClassStudent>,
private readonly dingTalkService: DingTalkService, private readonly dingTalkService: DingTalkService,
private readonly weComService: WeComService, private readonly weComService: WeComService,
private readonly attendanceImportService: AttendanceImportService, private readonly attendanceImportService: AttendanceImportService,
@@ -255,7 +253,7 @@ export class SyncService {
const tc = await manager.count(ClassTeacher, { where: { classId } }); const tc = await manager.count(ClassTeacher, { where: { classId } });
const sc = await manager.count(ClassStudent, { where: { classId } }); const sc = await manager.count(ClassStudent, { where: { classId } });
if (tc === 0 && sc === 0) { if (tc === 0 && sc === 0) {
const cls = await this.classRepo.findOne({ where: { id: classId } }); const cls = await manager.findOne(ClassEntity, { where: { id: classId } });
warnings.push(`班级 "${cls?.name}" (deptId=${deptId}) 无任何师生`); warnings.push(`班级 "${cls?.name}" (deptId=${deptId}) 无任何师生`);
} }
} }