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

71 lines
1.7 KiB
TypeScript

import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
ManyToOne,
JoinColumn,
} from 'typeorm';
import { Student } from './student.entity';
import { Room } from './room.entity';
import { Tenant } from './tenant.entity';
import { Department } from './department.entity';
@Entity('occupancies')
export class Occupancy {
@PrimaryGeneratedColumn()
id: number;
@Column({ name: 'student_id' })
studentId: number;
@Column({ name: 'room_id' })
roomId: number;
@Column({ name: 'check_in_date', type: 'date' })
checkInDate: string;
@Column({ name: 'check_out_date', type: 'date', nullable: true })
checkOutDate: string;
@Column({ name: 'billing_start_date', type: 'date' })
billingStartDate: string;
@Column({ name: 'billing_end_date', type: 'date', nullable: true })
billingEndDate: string;
@Column({ name: 'check_out_reason', length: 100, nullable: true })
checkOutReason: string;
@Column({ type: 'text', nullable: true })
notes: string;
@Column({ name: 'rental_type', length: 10, default: 'short' })
rentalType: string;
@Column({ name: 'tenant_id', type: 'integer', nullable: true })
tenantId: number;
@ManyToOne(() => Tenant, { nullable: true })
@JoinColumn({ name: 'tenant_id' })
tenant: Tenant;
@CreateDateColumn({ name: 'created_at' })
createdAt: Date;
@ManyToOne(() => Student, (s) => s.occupancies)
@JoinColumn({ name: 'student_id' })
student: Student;
@ManyToOne(() => Room, (r) => r.occupancies)
@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;
}