Files
gongxue-base/apps/server/src/entities/classroom-rental.entity.ts

81 lines
2.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import {
Entity,
PrimaryGeneratedColumn,
Column,
ManyToOne,
JoinColumn,
CreateDateColumn,
UpdateDateColumn,
Index,
} from 'typeorm';
import { Classroom } from './classroom.entity';
import { Organization } from './organization.entity';
export enum ClassroomRentalStatus {
ACTIVE = 'active',
ENDED = 'ended',
CANCELLED = 'cancelled',
}
@Entity('classroom_rentals')
@Index(['classroomId', 'startDate', 'endDate'])
export class ClassroomRental {
@PrimaryGeneratedColumn()
id: number;
@Column({ name: 'classroom_id' })
classroomId: number;
@ManyToOne(() => Classroom)
@JoinColumn({ name: 'classroom_id' })
classroom: Classroom;
@Column({ name: 'lessor_organization_id', nullable: true })
lessorOrganizationId: number;
@ManyToOne(() => Organization)
@JoinColumn({ name: 'lessor_organization_id' })
lessorOrganization: Organization;
@Column({ name: 'lessee_organization_id', nullable: true })
lesseeOrganizationId: number;
@ManyToOne(() => Organization)
@JoinColumn({ name: 'lessee_organization_id' })
lesseeOrganization: Organization;
@Column({ name: 'start_date', type: 'date' })
startDate: string;
@Column({ name: 'end_date', type: 'date' })
endDate: string;
// 合同 PDF 相对路径(相对 UPLOAD_DIR仅存文件名
@Column({ name: 'contract_path', length: 255, nullable: true })
contractPath: string;
@Column({ name: 'contract_original_name', length: 255, nullable: true })
contractOriginalName: string;
@Column({ name: 'daily_rate', type: 'decimal', precision: 10, scale: 2, nullable: true })
dailyRate: number;
@Column({ name: 'total_amount', type: 'decimal', precision: 10, scale: 2, nullable: true })
totalAmount: number;
@Column({ type: 'varchar', length: 20, default: ClassroomRentalStatus.ACTIVE })
status: ClassroomRentalStatus | 'active' | 'ended' | 'cancelled';
@Column({ type: 'text', nullable: true })
notes: string;
@Column({ name: 'created_by', nullable: true })
createdBy: number;
@CreateDateColumn({ name: 'created_at' })
createdAt: Date;
@UpdateDateColumn({ name: 'updated_at' })
updatedAt: Date;
}