- Delete department.entity.ts, user-department.entity.ts - Remove Department/UserDepartment from entities/index.ts - Remove departmentId column from 18 entities (AttendanceRecord, ArchiveAttachment, Bill, ClassSchedule, Classroom, ClassroomRental, Deposit, DepositInstallment, ExamScore, LearningRecord, Occupancy, PersonalExpense, ResultArchive, Room, RoomExpense, Student, StudentEnrollment, StudentProfile, StudentReport) - Remove departments/ module entirely - Delete campus-scope.ts, campus-scope.middleware.ts (request-utils.ts kept — it's just IP extraction) - Simplify common.module.ts to empty module - Remove CampusScopeMiddleware from app.module.ts - Remove all CampusScope injections and filter calls across all services - Remove departmentId from all DTOs and controllers - Simplify dingtalk/wecom sync to only sync users (no dept table) - Update seed module to remove department seeding - Clean frontend compilation
59 lines
1.8 KiB
TypeScript
59 lines
1.8 KiB
TypeScript
import { Module, OnModuleInit, Logger } from '@nestjs/common';
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
import { SeedDevService } from './seed-dev.service';
|
|
import {
|
|
Student, Room, Occupancy, RoomExpense,
|
|
Bill, BillItem, User, Deposit,
|
|
Classroom, Tenant, ClassroomRental, Permission, Role,
|
|
Class, ClassStudent, ClassTeacher, ClassSchedule,
|
|
AttendanceRecord,
|
|
StudentProfile, StudentEnrollment, ExamScore, LearningRecord,
|
|
ExpenseType,
|
|
} from '../entities';
|
|
|
|
const SEED_ENTITIES = [
|
|
User, Role, Permission,
|
|
Tenant, Student, Room, Classroom, Occupancy,
|
|
RoomExpense, ExpenseType, Class,
|
|
ClassStudent, ClassTeacher, ClassSchedule, Bill, BillItem,
|
|
Deposit, AttendanceRecord,
|
|
ClassroomRental, StudentProfile, StudentEnrollment,
|
|
ExamScore, LearningRecord,
|
|
];
|
|
|
|
@Module({
|
|
imports: [TypeOrmModule.forFeature(SEED_ENTITIES)],
|
|
providers: [SeedDevService],
|
|
})
|
|
export class SeedModule implements OnModuleInit {
|
|
private readonly logger = new Logger(SeedModule.name);
|
|
|
|
constructor(private readonly seedService: SeedDevService) {}
|
|
|
|
async onModuleInit() {
|
|
const enabled = process.env['SEED_DEV'] === 'true';
|
|
const skip = process.env['SEED_DEV_SKIP'] === 'true';
|
|
|
|
if (!enabled || skip) {
|
|
this.logger.log(
|
|
`Seed skipped: SEED_DEV=${process.env['SEED_DEV']}, NODE_ENV=${process.env['NODE_ENV']}, SKIP=${skip}`,
|
|
);
|
|
return;
|
|
}
|
|
|
|
const studentCount = await this.seedService.getStudentCount();
|
|
if (studentCount > 0) {
|
|
this.logger.log(`Seed skipped: ${studentCount} students already exist`);
|
|
return;
|
|
}
|
|
|
|
this.logger.log('Starting mock data seeding...');
|
|
try {
|
|
await this.seedService.seed();
|
|
this.logger.log('Mock data seeding completed successfully');
|
|
} catch (err) {
|
|
this.logger.error('Mock data seeding failed', err instanceof Error ? err.stack : String(err));
|
|
}
|
|
}
|
|
}
|