import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm"; import { EntityBase } from "./base/Base"; import { Profile } from "./Profile"; 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, type: "datetime", comment: "วันที่หมดอายุ", default: null, }) expireDate: Date; @Column({ comment: "สถานะการใช้งาน", default: false, }) isActive: boolean; @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; } export class CreateProfileCertificate { profileId: string | null; expireDate: Date | null; isActive: boolean; issueDate: Date | null; certificateNo: string | null; certificateType: string | null; issuer: string | null; } export type UpdateProfileCertificate = { expireDate?: Date | null; isActive?: boolean; issueDate?: Date | null; certificateNo?: string | null; certificateType?: string | null; issuer?: string | null; };