import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; import { EntityBase } from "./base/Base"; import { Profile } from "./Profile"; import { ProfileLeaveHistory } from "./ProfileLeaveHistory"; import { LeaveType } from "./LeaveType"; @Entity("profileLeave") export class ProfileLeave extends EntityBase { @Column({ nullable: true, length: 40, comment: "คีย์นอก(FK)ของตาราง Profile", default: null, }) profileId: string; @Column({ nullable: true, length: 40, comment: "คีย์นอก(FK)ของตาราง LeaveType", default: null, }) leaveTypeId: string; @Column({ nullable: true, type: "datetime", comment: "วัน เดือน ปี ที่ลา", default: null, }) dateLeave: Date; @Column({ nullable: true, type: "double", comment: "จำนวนวันลา", default: null, }) leaveDays: number; @Column({ nullable: true, type: "double", comment: "ลามาเเล้ว", default: null, }) leaveCount: number; @Column({ nullable: true, type: "double", comment: "รวมเป็น", default: null, }) totalLeave: number; @Column({ nullable: true, comment: "สถานะ", type: "text", default: null, }) status: string; @Column({ nullable: true, comment: "เหตุผล", type: "text", default: null, }) reason: string; @OneToMany(() => ProfileLeaveHistory, (v) => v.histories) profileLeaves: ProfileLeaveHistory[]; @ManyToOne(() => LeaveType, (v) => v.profileLeave) leaveType: LeaveType; @ManyToOne(() => Profile, (v) => v.profileLeaves) profile: Profile; } export class CreateProfileLeave { profileId: string | null; leaveTypeId: string | null; dateLeave: Date | null; leaveDays: number | null; leverCount: number | null; totalLeave: number | null; status: string | null; reason: string | null; } export type UpdateProfileLeave = { dateLeave?: Date | null; leaveDays?: number | null; leverCount?: number | null; totalLeave?: number | null; status?: string | null; reason?: string | null; };