add entity org part 1

This commit is contained in:
AdisakKanthawilang 2024-03-12 14:53:15 +07:00
parent 0f7edf5d15
commit f36ff656ef
13 changed files with 1783 additions and 1 deletions

View file

@ -0,0 +1,96 @@
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 {
@Column("uuid")
profileId: string | null;
@Column()
expireDate: Date | null;
@Column()
isActive: boolean;
@Column()
issueDate: Date | null;
@Column()
certificateNo: string | null;
@Column()
certificateType: string | null;
@Column()
issuer: string | null;
}
export type UpdateProfileCertificate = Partial<CreateProfileCertificate>;