104 lines
2.6 KiB
TypeScript
104 lines
2.6 KiB
TypeScript
import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm";
|
|
import { EntityBase } from "./base/Base";
|
|
import { Profile } from "./Profile";
|
|
import { ProfileEmployee } from "./ProfileEmployee";
|
|
import { ProfileCertificateHistory } from "./ProfileCertificateHistory";
|
|
|
|
@Entity("profileCertificate")
|
|
export class ProfileCertificate extends EntityBase {
|
|
@Column({
|
|
nullable: true,
|
|
length: 40,
|
|
comment: "คีย์นอก(FK)ของตาราง Profile",
|
|
default: null,
|
|
})
|
|
profileId: string;
|
|
|
|
@Column({
|
|
nullable: true,
|
|
length: 40,
|
|
comment: "คีย์นอก(FK)ของตาราง ProfileEmployee",
|
|
default: null,
|
|
})
|
|
profileEmployeeId: string;
|
|
|
|
@Column({
|
|
nullable: true,
|
|
type: "datetime",
|
|
comment: "วันที่หมดอายุ",
|
|
default: null,
|
|
})
|
|
expireDate: Date;
|
|
|
|
@Column({
|
|
nullable: true,
|
|
type: "datetime",
|
|
comment: "วันที่ออกใบอนุญาต",
|
|
default: null,
|
|
})
|
|
issueDate: Date;
|
|
|
|
@Column({
|
|
nullable: true,
|
|
comment: "เลขที่ใบอนุญาต",
|
|
length: 20,
|
|
default: null,
|
|
})
|
|
certificateNo: string;
|
|
|
|
@Column({
|
|
nullable: true,
|
|
comment: "ชื่อใบอนุญาต",
|
|
length: 100,
|
|
default: null,
|
|
})
|
|
certificateType: string;
|
|
|
|
@Column({
|
|
nullable: true,
|
|
comment: "หน่วยงานผู้ออกใบอนุญาต",
|
|
length: 200,
|
|
default: null,
|
|
})
|
|
issuer: string;
|
|
|
|
@OneToMany(
|
|
() => ProfileCertificateHistory,
|
|
(profileCertificateHistory) => profileCertificateHistory.histories,
|
|
)
|
|
profileCertificateHistories: ProfileCertificateHistory[];
|
|
|
|
@ManyToOne(() => Profile, (profile) => profile.profileCertificates)
|
|
@JoinColumn({ name: "profileId" })
|
|
profile: Profile;
|
|
|
|
@ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileCertificates)
|
|
@JoinColumn({ name: "profileEmployeeId" })
|
|
profileEmployee: ProfileEmployee;
|
|
}
|
|
|
|
export class CreateProfileCertificate {
|
|
profileId: string | null;
|
|
expireDate: Date | null;
|
|
issueDate: Date | null;
|
|
certificateNo: string | null;
|
|
certificateType: string | null;
|
|
issuer: string | null;
|
|
}
|
|
|
|
export class CreateProfileEmployeeCertificate {
|
|
profileEmployeeId: string | null;
|
|
expireDate: Date | null;
|
|
issueDate: Date | null;
|
|
certificateNo: string | null;
|
|
certificateType: string | null;
|
|
issuer: string | null;
|
|
}
|
|
|
|
export type UpdateProfileCertificate = {
|
|
expireDate?: Date | null;
|
|
issueDate?: Date | null;
|
|
certificateNo?: string | null;
|
|
certificateType?: string | null;
|
|
issuer?: string | null;
|
|
};
|