hrms-api-org/src/entities/ProfileDuty.ts
2024-03-21 14:29:45 +07:00

90 lines
2 KiB
TypeScript

import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { Profile } from "./Profile";
import { ProfileDutyHistory } from "./ProfileDutyHistory";
@Entity("profileDuty")
export class ProfileDuty extends EntityBase {
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง Profile",
default: null,
})
profileId: string;
@Column({
nullable: true,
type: "datetime",
comment: "เริ่มต้น",
default: null,
})
dateStart: Date;
@Column({
nullable: true,
type: "datetime",
comment: "สิ้นสุด",
default: null,
})
dateEnd: Date;
@Column({
nullable: true,
comment: "รายละเอียด",
type: "text",
default: null,
})
detail: string;
@Column({
nullable: true,
comment: "เอกสารอ้างอิง",
type: "text",
default: null,
})
reference: string;
@Column({
nullable: true,
type: "datetime",
comment: "เอกสารอ้างอิง (ลงวันที่)",
default: null,
})
refCommandDate: Date;
@Column({
nullable: true,
comment: "เอกสารอ้างอิง (เลขที่คำสั่ง)",
type: "text",
default: null,
})
refCommandNo: string;
@OneToMany(() => ProfileDutyHistory, (profileDutyHistory) => profileDutyHistory.histories)
profileDutyHistories: ProfileDutyHistory[];
@ManyToOne(() => Profile, (profile) => profile.profileDutys)
@JoinColumn({ name: "profileId" })
profile: Profile;
}
export class CreateProfileDuty {
profileId: string | null;
dateStart: Date | null;
dateEnd: Date | null;
detail: string | null;
reference: string | null;
refCommandDate: Date | null;
refCommandNo: string | null;
}
export type UpdateProfileDuty = {
dateStart?: Date | null;
dateEnd?: Date | null;
detail?: string | null;
reference?: string | null;
refCommandDate?: Date | null;
refCommandNo?: string | null;
};