hrms-api-org/src/entities/ProfileDuty.ts

98 lines
2.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({
comment: "สถานะการใช้งาน",
default: false,
})
isActive: boolean;
@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;
isActive: boolean;
dateStart: Date | null;
dateEnd: Date | null;
detail: string | null;
reference: string | null;
refCommandDate: Date | null;
refCommandNo: string | null;
}
export type UpdateProfileDuty = {
profileId: string | null;
isActive: boolean;
dateStart?: Date | null;
dateEnd?: Date | null;
detail: string | null;
reference: string | null;
refCommandDate?: Date | null;
refCommandNo: string | null;
};