import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm"; import { EntityBase } from "./base/Base"; import { PosType } from "./PosType"; import { profile } from "console"; import { Salarys } from "./Salarys"; enum PosLevelAuthority { HEAD = "HEAD", DEPUTY = "DEPUTY", GOVERNOR = "GOVERNOR", } @Entity("posLevel") export class PosLevel extends EntityBase { @Column({ nullable: true, comment: "ชื่อระดับตำแหน่ง", length: 255, default: null, }) posLevelName: string; @Column({ nullable: true, comment: "ระดับของระดับตำแหน่ง", default: null, }) posLevelRank: number; @Column({ nullable: true, comment: "ผู้มีอำนาจสั่งบรรจุของระดับนี้ head = หัวหน้าหน่วยงาน , deputy = ปลัด , governor = ผู้ว่าฯ", type: "enum", enum: PosLevelAuthority, default: null, }) posLevelAuthority: PosLevelAuthority; @Column({ length: 40, comment: "คีย์นอก(FK)ของตาราง posType", }) posTypeId: string; @OneToMany(() => Salarys, (salary) => salary.posLevel_) salarys_: Salarys[]; @ManyToOne(() => PosType, (posType) => posType.posLevels) @JoinColumn({ name: "posTypeId" }) posType: PosType; } export class CreatePosLevel { @Column() posLevelName: string; @Column() posLevelRank: number; @Column() posLevelAuthority: string; @Column("uuid") posTypeId: string; } export type UpdatePosLevel = Partial & { posLevelAuthority?: PosLevelAuthority };