From 8b2c20ec57f5be73d404362d4579df08042cc01d Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 12 Mar 2024 17:52:22 +0700 Subject: [PATCH] checkpoint --- src/entities/Profile.ts | 4 + src/entities/ProfileAbility.ts | 104 ++++++++++++++++++++++++++ src/entities/ProfileAbilityHistory.ts | 103 +++++++++++++++++++++++++ 3 files changed, 211 insertions(+) create mode 100644 src/entities/ProfileAbility.ts create mode 100644 src/entities/ProfileAbilityHistory.ts diff --git a/src/entities/Profile.ts b/src/entities/Profile.ts index e785d845..4d9c583d 100644 --- a/src/entities/Profile.ts +++ b/src/entities/Profile.ts @@ -12,6 +12,7 @@ import { ProfileInsignia } from "./ProfileInsignia"; import { ProfileHonor } from "./ProfileHonor"; import { ProfileAssessment } from "./ProfileAssessment"; import { ProfileLeave } from "./ProfileLeave"; +import { ProfileAbility } from "./ProfileAbility"; @Entity("profile") export class Profile extends EntityBase { @@ -165,6 +166,9 @@ export class Profile extends EntityBase { @OneToMany(() => ProfileLeave, (profileLeave) => profileLeave.profile) profileLeaves: ProfileLeave[]; + @OneToMany(() => ProfileAbility, (profileAbility) => profileAbility.profile) + profileAbilities: ProfileAbility[]; + @ManyToOne(() => PosLevel, (posLevel) => posLevel.posLevels) @JoinColumn({ name: "posLevelId" }) posLevel: PosLevel; diff --git a/src/entities/ProfileAbility.ts b/src/entities/ProfileAbility.ts new file mode 100644 index 00000000..697c34e3 --- /dev/null +++ b/src/entities/ProfileAbility.ts @@ -0,0 +1,104 @@ +import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { Profile } from "./Profile"; +import { ProfileAbilityHistory } from "./ProfileAbilityHistory"; + +@Entity("profileAbility") +export class ProfileAbility extends EntityBase { + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง Profile", + default: null, + }) + profileId: string; + + @Column({ + comment: "สถานะการใช้งาน", + default: false, + }) + isActive: boolean; + + @Column({ + nullable: true, + comment: "หมายเหตุ", + type: "text", + default: null, + }) + remark: string; + + @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, + }) + dateStart: Date; + + @Column({ + nullable: true, + type: "datetime", + comment: "วันที่สิ้นสุด", + default: null, + }) + dateEnd: Date; + + @Column({ + nullable: true, + comment: "ด้าน", + type: "text", + default: null, + }) + field: string; + + @OneToMany(() => ProfileAbilityHistory, (profileAbilityHistory) => profileAbilityHistory.histories) + profileAbilityHistorys: ProfileAbilityHistory[]; + + @ManyToOne(() => Profile, (profile) => profile.profileAbilities) + @JoinColumn({ name: "profileId" }) + profile: Profile; +} + +export class CreateProfileAbility { + @Column("uuid") + profileId: string | null; + + @Column() + isActive: boolean; + + @Column() + remark: string | null; + + @Column() + detail: string | null; + + @Column() + reference: string | null; + + @Column() + dateStart: Date | null; + + @Column() + dateEnd: Date | null; + + @Column() + field: string | null; +} + +export type UpdateProfileAbility = Partial; diff --git a/src/entities/ProfileAbilityHistory.ts b/src/entities/ProfileAbilityHistory.ts new file mode 100644 index 00000000..61f6364b --- /dev/null +++ b/src/entities/ProfileAbilityHistory.ts @@ -0,0 +1,103 @@ +import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { Profile } from "./Profile"; +import { ProfileAbility } from "./ProfileAbility"; + +@Entity("profileAbilityHistory") +export class ProfileAbilityHistory extends EntityBase { + + @Column({ + comment: "สถานะการใช้งาน", + default: false, + }) + isActive: boolean; + + @Column({ + nullable: true, + comment: "หมายเหตุ", + type: "text", + default: null, + }) + remark: string; + + @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, + }) + dateStart: Date; + + @Column({ + nullable: true, + type: "datetime", + comment: "วันที่สิ้นสุด", + default: null, + }) + dateEnd: Date; + + @Column({ + nullable: true, + comment: "ด้าน", + type: "text", + default: null, + }) + field: string; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileAbility", + default: null, + }) + profileAbilityId: string; + + @ManyToOne(() => ProfileAbility, (profileAbility) => profileAbility.profileAbilityHistorys) + @JoinColumn({ name: "profileAbilityId" }) + histories: ProfileAbility; +} + +export class CreateProfileAbilityHistory { + + @Column() + isActive: boolean; + + @Column() + remark: string | null; + + @Column() + detail: string | null; + + @Column() + reference: string | null; + + @Column() + dateStart: Date | null; + + @Column() + dateEnd: Date | null; + + @Column() + field: string | null; + + @Column("uuid") + ProfileAbilityId: string | null; +} + +export type UpdateProfileAbilityHistory = Partial;