forked from wangziqi/gongxue-base
refactor(server): remove Department/UserDepartment entities, CampusScope, and departmentId from all entities
- 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
This commit is contained in:
@@ -8,7 +8,6 @@ import {
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
import { Student } from './student.entity';
|
||||
import { Department } from './department.entity';
|
||||
|
||||
@Entity('archive_attachments')
|
||||
export class ArchiveAttachment {
|
||||
@@ -37,12 +36,6 @@ export class ArchiveAttachment {
|
||||
@Column({ name: 'mime_type', length: 100, nullable: true })
|
||||
mimeType: string;
|
||||
|
||||
@Column({ name: 'department_id', type: 'integer', nullable: true })
|
||||
departmentId: number;
|
||||
|
||||
@ManyToOne(() => Department, { nullable: true })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
|
||||
@CreateDateColumn({ name: 'created_at' })
|
||||
createdAt: Date;
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
} from 'typeorm';
|
||||
import { Student } from './student.entity';
|
||||
import { Class } from './class.entity';
|
||||
import { Department } from './department.entity';
|
||||
|
||||
@Entity('attendance_records')
|
||||
@Index(['classId', 'attendanceDate'])
|
||||
@@ -54,10 +53,4 @@ export class AttendanceRecord {
|
||||
@UpdateDateColumn({ name: 'updated_at' })
|
||||
updatedAt: Date;
|
||||
|
||||
@Column({ name: 'department_id', type: 'integer', nullable: true })
|
||||
departmentId: number;
|
||||
|
||||
@ManyToOne(() => Department, { nullable: true })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
} from 'typeorm';
|
||||
import { Student } from './student.entity';
|
||||
import { BillItem } from './bill-item.entity';
|
||||
import { Department } from './department.entity';
|
||||
|
||||
@Entity('bills')
|
||||
export class Bill {
|
||||
@@ -47,10 +46,4 @@ export class Bill {
|
||||
@OneToMany(() => BillItem, (bi) => bi.bill)
|
||||
items: BillItem[];
|
||||
|
||||
@Column({ name: 'department_id', type: 'integer', nullable: true })
|
||||
departmentId: number;
|
||||
|
||||
@ManyToOne(() => Department, { nullable: true })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
JoinColumn,
|
||||
Check,
|
||||
} from 'typeorm';
|
||||
import { Department } from './department.entity';
|
||||
|
||||
export enum ScheduleType {
|
||||
INTERNAL = 'INTERNAL',
|
||||
@@ -81,10 +80,4 @@ export class ClassSchedule {
|
||||
@UpdateDateColumn({ name: 'updated_at' })
|
||||
updatedAt: Date;
|
||||
|
||||
@Column({ name: 'department_id', type: 'integer', nullable: true })
|
||||
departmentId: number;
|
||||
|
||||
@ManyToOne(() => Department, { nullable: true })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
} from 'typeorm';
|
||||
import { Classroom } from './classroom.entity';
|
||||
import { Tenant } from './tenant.entity';
|
||||
import { Department } from './department.entity';
|
||||
|
||||
@Entity('classroom_rentals')
|
||||
@Index(['classroomId', 'startDate', 'endDate'])
|
||||
@@ -66,10 +65,4 @@ export class ClassroomRental {
|
||||
@UpdateDateColumn({ name: 'updated_at' })
|
||||
updatedAt: Date;
|
||||
|
||||
@Column({ name: 'department_id', type: 'integer', nullable: true })
|
||||
departmentId: number;
|
||||
|
||||
@ManyToOne(() => Department, { nullable: true })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, ManyToOne, JoinColumn } from 'typeorm';
|
||||
import { Department } from './department.entity';
|
||||
|
||||
@Entity('classrooms')
|
||||
export class Classroom {
|
||||
@@ -36,10 +35,4 @@ export class Classroom {
|
||||
@CreateDateColumn({ name: 'created_at' })
|
||||
createdAt: Date;
|
||||
|
||||
@Column({ name: 'department_id', type: 'integer', nullable: true })
|
||||
departmentId: number;
|
||||
|
||||
@ManyToOne(() => Department, { nullable: true })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
}
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
export enum DepartmentType {
|
||||
CAMPUS = 'campus',
|
||||
DEPARTMENT = 'department',
|
||||
}
|
||||
|
||||
@Entity('departments')
|
||||
export class Department {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column({ length: 100 })
|
||||
name: string;
|
||||
|
||||
@Column({ name: 'parent_id', type: 'integer', nullable: true })
|
||||
parentId: number;
|
||||
|
||||
@ManyToOne(() => Department, { nullable: true, onDelete: 'SET NULL' })
|
||||
@JoinColumn({ name: 'parent_id' })
|
||||
parent: Department;
|
||||
|
||||
@OneToMany(() => Department, (d) => d.parent)
|
||||
children: Department[];
|
||||
|
||||
@Column({ length: 20, default: DepartmentType.DEPARTMENT })
|
||||
type: string;
|
||||
|
||||
@Column({ name: 'sort_order', type: 'integer', default: 0 })
|
||||
sortOrder: number;
|
||||
|
||||
@Column({ length: 20, default: 'active' })
|
||||
status: string;
|
||||
|
||||
@Column({ length: 20, nullable: true })
|
||||
source: string;
|
||||
|
||||
@Column({ name: 'source_id', length: 50, nullable: true })
|
||||
sourceId: string;
|
||||
|
||||
@Column({ name: 'parent_source_id', length: 50, nullable: true })
|
||||
parentSourceId: string;
|
||||
|
||||
@CreateDateColumn({ name: 'created_at' })
|
||||
createdAt: Date;
|
||||
|
||||
@UpdateDateColumn({ name: 'updated_at' })
|
||||
updatedAt: Date;
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
import { Deposit } from './deposit.entity';
|
||||
import { Department } from './department.entity';
|
||||
|
||||
@Entity('deposit_installments')
|
||||
export class DepositInstallment {
|
||||
@@ -36,10 +35,4 @@ export class DepositInstallment {
|
||||
@JoinColumn({ name: 'deposit_id' })
|
||||
deposit: Deposit;
|
||||
|
||||
@Column({ name: 'department_id', type: 'integer', nullable: true })
|
||||
departmentId: number;
|
||||
|
||||
@ManyToOne(() => Department, { nullable: true })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
} from 'typeorm';
|
||||
import { Student } from './student.entity';
|
||||
import { DepositInstallment } from './deposit-installment.entity';
|
||||
import { Department } from './department.entity';
|
||||
|
||||
@Entity('deposits')
|
||||
export class Deposit {
|
||||
@@ -72,10 +71,4 @@ export class Deposit {
|
||||
@JoinColumn({ name: 'student_id' })
|
||||
student: Student;
|
||||
|
||||
@Column({ name: 'department_id', type: 'integer', nullable: true })
|
||||
departmentId: number;
|
||||
|
||||
@ManyToOne(() => Department, { nullable: true })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
} from 'typeorm';
|
||||
import { Student } from './student.entity';
|
||||
import { StudentEnrollment } from './student-enrollment.entity';
|
||||
import { Department } from './department.entity';
|
||||
|
||||
@Entity('exam_scores')
|
||||
export class ExamScore {
|
||||
@@ -51,12 +50,6 @@ export class ExamScore {
|
||||
@Column({ name: 'exam_date', type: 'date', nullable: true })
|
||||
examDate: string;
|
||||
|
||||
@Column({ name: 'department_id', type: 'integer', nullable: true })
|
||||
departmentId: number;
|
||||
|
||||
@ManyToOne(() => Department, { nullable: true })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
|
||||
@CreateDateColumn({ name: 'created_at' })
|
||||
createdAt: Date;
|
||||
|
||||
@@ -26,8 +26,6 @@ export { SyncLog } from './sync-log.entity';
|
||||
export { SyncState } from './sync-state.entity';
|
||||
export { ExpenseType } from './expense-type.entity';
|
||||
export { Notification, NotificationType } from './notification.entity';
|
||||
export { Department, DepartmentType } from './department.entity';
|
||||
export { UserDepartment } from './user-department.entity';
|
||||
export { StudentProfile } from './student-profile.entity';
|
||||
export { StudentEnrollment } from './student-enrollment.entity';
|
||||
export { ExamScore } from './exam-score.entity';
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
import { Student } from './student.entity';
|
||||
import { Department } from './department.entity';
|
||||
|
||||
@Entity('learning_records')
|
||||
export class LearningRecord {
|
||||
@@ -37,12 +36,6 @@ export class LearningRecord {
|
||||
@Column({ name: 'next_step', type: 'text', nullable: true })
|
||||
nextStep: string;
|
||||
|
||||
@Column({ name: 'department_id', type: 'integer', nullable: true })
|
||||
departmentId: number;
|
||||
|
||||
@ManyToOne(() => Department, { nullable: true })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
|
||||
@CreateDateColumn({ name: 'created_at' })
|
||||
createdAt: Date;
|
||||
|
||||
@@ -11,7 +11,6 @@ import { Room } from './room.entity';
|
||||
import { Tenant } from './tenant.entity';
|
||||
import { Bed } from './bed.entity';
|
||||
import { Locker } from './locker.entity';
|
||||
import { Department } from './department.entity';
|
||||
|
||||
@Entity('occupancies')
|
||||
export class Occupancy {
|
||||
@@ -77,10 +76,4 @@ export class Occupancy {
|
||||
@JoinColumn({ name: 'room_id' })
|
||||
room: Room;
|
||||
|
||||
@Column({ name: 'department_id', type: 'integer', nullable: true })
|
||||
departmentId: number;
|
||||
|
||||
@ManyToOne(() => Department, { nullable: true })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
import { Student } from './student.entity';
|
||||
import { Department } from './department.entity';
|
||||
|
||||
@Entity('personal_expenses')
|
||||
export class PersonalExpense {
|
||||
@@ -42,10 +41,4 @@ export class PersonalExpense {
|
||||
@JoinColumn({ name: 'student_id' })
|
||||
student: Student;
|
||||
|
||||
@Column({ name: 'department_id', type: 'integer', nullable: true })
|
||||
departmentId: number;
|
||||
|
||||
@ManyToOne(() => Department, { nullable: true })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
import { Student } from './student.entity';
|
||||
import { Department } from './department.entity';
|
||||
|
||||
@Entity('result_archives')
|
||||
export class ResultArchive {
|
||||
@@ -37,12 +36,6 @@ export class ResultArchive {
|
||||
@Column({ name: 'admitted_major', length: 100, nullable: true })
|
||||
admittedMajor: string;
|
||||
|
||||
@Column({ name: 'department_id', type: 'integer', nullable: true })
|
||||
departmentId: number;
|
||||
|
||||
@ManyToOne(() => Department, { nullable: true })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
|
||||
@CreateDateColumn({ name: 'created_at' })
|
||||
createdAt: Date;
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
import { Room } from './room.entity';
|
||||
import { Department } from './department.entity';
|
||||
|
||||
@Entity('room_expenses')
|
||||
export class RoomExpense {
|
||||
@@ -42,10 +41,4 @@ export class RoomExpense {
|
||||
@JoinColumn({ name: 'room_id' })
|
||||
room: Room;
|
||||
|
||||
@Column({ name: 'department_id', type: 'integer', nullable: true })
|
||||
departmentId: number;
|
||||
|
||||
@ManyToOne(() => Department, { nullable: true })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, OneToMany, ManyToOne, JoinColumn } from 'typeorm';
|
||||
import { Occupancy } from './occupancy.entity';
|
||||
import { RoomExpense } from './room-expense.entity';
|
||||
import { Department } from './department.entity';
|
||||
|
||||
@Entity('rooms')
|
||||
export class Room {
|
||||
@@ -44,10 +43,4 @@ export class Room {
|
||||
@OneToMany(() => RoomExpense, (e) => e.room)
|
||||
roomExpenses: RoomExpense[];
|
||||
|
||||
@Column({ name: 'department_id', type: 'integer', nullable: true })
|
||||
departmentId: number;
|
||||
|
||||
@ManyToOne(() => Department, { nullable: true })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
import { Student } from './student.entity';
|
||||
import { Department } from './department.entity';
|
||||
|
||||
@Entity('student_enrollments')
|
||||
export class StudentEnrollment {
|
||||
@@ -46,12 +45,6 @@ export class StudentEnrollment {
|
||||
@Column({ length: 20, default: 'active' })
|
||||
status: string;
|
||||
|
||||
@Column({ name: 'department_id', type: 'integer', nullable: true })
|
||||
departmentId: number;
|
||||
|
||||
@ManyToOne(() => Department, { nullable: true })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
|
||||
@CreateDateColumn({ name: 'created_at' })
|
||||
createdAt: Date;
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
import { Student } from './student.entity';
|
||||
import { Department } from './department.entity';
|
||||
|
||||
@Entity('student_profiles')
|
||||
export class StudentProfile {
|
||||
@@ -43,12 +42,6 @@ export class StudentProfile {
|
||||
@Column({ type: 'text', nullable: true })
|
||||
notes: string;
|
||||
|
||||
@Column({ name: 'department_id', type: 'integer', nullable: true })
|
||||
departmentId: number;
|
||||
|
||||
@ManyToOne(() => Department, { nullable: true })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
|
||||
@CreateDateColumn({ name: 'created_at' })
|
||||
createdAt: Date;
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
import { Student } from './student.entity';
|
||||
import { Department } from './department.entity';
|
||||
|
||||
@Entity('student_reports')
|
||||
export class StudentReport {
|
||||
@@ -34,12 +33,6 @@ export class StudentReport {
|
||||
@Column({ name: 'generated_at', type: 'datetime', nullable: true })
|
||||
generatedAt: Date;
|
||||
|
||||
@Column({ name: 'department_id', type: 'integer', nullable: true })
|
||||
departmentId: number;
|
||||
|
||||
@ManyToOne(() => Department, { nullable: true })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
|
||||
@CreateDateColumn({ name: 'created_at' })
|
||||
createdAt: Date;
|
||||
|
||||
@@ -14,7 +14,6 @@ import { PersonalExpense } from './personal-expense.entity';
|
||||
import { Bill } from './bill.entity';
|
||||
import { Tenant } from './tenant.entity';
|
||||
import { User } from './user.entity';
|
||||
import { Department } from './department.entity';
|
||||
|
||||
@Entity('students')
|
||||
export class Student {
|
||||
@@ -82,10 +81,4 @@ export class Student {
|
||||
@OneToMany(() => Bill, (b) => b.student)
|
||||
bills: Bill[];
|
||||
|
||||
@Column({ name: 'department_id', type: 'integer', nullable: true })
|
||||
departmentId: number;
|
||||
|
||||
@ManyToOne(() => Department, { nullable: true })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
Unique,
|
||||
} from 'typeorm';
|
||||
import { User } from './user.entity';
|
||||
import { Department } from './department.entity';
|
||||
|
||||
@Entity('user_departments')
|
||||
@Unique(['userId', 'departmentId'])
|
||||
export class UserDepartment {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column({ name: 'user_id', type: 'integer' })
|
||||
userId: number;
|
||||
|
||||
@ManyToOne(() => User, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'user_id' })
|
||||
user: User;
|
||||
|
||||
@Column({ name: 'department_id', type: 'integer' })
|
||||
departmentId: number;
|
||||
|
||||
@ManyToOne(() => Department, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
|
||||
@Column({ name: 'is_default', type: 'boolean', default: false })
|
||||
isDefault: boolean;
|
||||
|
||||
@CreateDateColumn({ name: 'created_at' })
|
||||
createdAt: Date;
|
||||
}
|
||||
Reference in New Issue
Block a user