import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; import { EntityBase } from "./base/Base"; import { EmployeePosDict } from "./EmployeePosDict"; import { EmployeePosType } from "./EmployeePosType"; import { EmployeePosition } from "./EmployeePosition"; import { ProfileEmployee } from "./ProfileEmployee"; enum EmployeePosLevelAuthoritys { HEAD = "HEAD", DEPUTY = "DEPUTY", GOVERNOR = "GOVERNOR", } @Entity("employeePosLevel") export class EmployeePosLevel extends EntityBase { @Column({ comment: "ชื่อระดับชั้นงาน", type: "int", }) posLevelName: number; @Column({ comment: "ระดับของระดับชั้นงาน", type: "int", }) posLevelRank: number; @Column({ nullable: true, comment: "ผู้มีอำนาจสั่งบรรจุของระดับนี้ head = หัวหน้าหน่วยงาน , deputy = ปลัด , governor = ผู้ว่าฯ", type: "enum", enum: EmployeePosLevelAuthoritys, default: null, }) posLevelAuthority: EmployeePosLevelAuthoritys; @Column({ length: 40, comment: "คีย์นอก(FK)ของตาราง employeePosType", }) posTypeId: string; @ManyToOne(() => EmployeePosType, (posType) => posType.posLevels) @JoinColumn({ name: "posTypeId" }) posType: EmployeePosType; @OneToMany(() => EmployeePosition, (position) => position.posLevel) positions: EmployeePosition[]; @OneToMany(() => EmployeePosDict, (posDict) => posDict.posLevel) posDicts: EmployeePosDict[]; @OneToMany(() => ProfileEmployee, (profile) => profile.posLevel) profiles: ProfileEmployee[]; } export class CreateEmployeePosLevel { @Column() posLevelName: number; @Column() posLevelRank: number; @Column() posLevelAuthority: string; @Column("uuid") posTypeId: string; } export type UpdateEmployeePosLevel = Partial & { posLevelAuthority: EmployeePosLevelAuthoritys; };