import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; import { EntityBase } from "./base/Base"; import { PosType } from "./PosType"; import { ActualGoal } from "./ActualGoal"; import { PlannedGoal } from "./PlannedGoal"; import { DevelopmentHistory } from "./DevelopmentHistory"; 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: "เป็นระดับของประเภทตำแหน่งใด", }) posTypeId: string; @ManyToOne(() => PosType, (posType: PosType) => posType.posLevels) @JoinColumn({ name: "posTypeId" }) posType: PosType; @OneToMany(() => ActualGoal, (actualGoal: ActualGoal) => actualGoal.posLevelActual) actualGoals: ActualGoal[]; @OneToMany(() => PlannedGoal, (plannedGoal: PlannedGoal) => plannedGoal.posLevelPlanned) plannedGoals: PlannedGoal[]; @OneToMany(() => DevelopmentHistory, (developmentHistory) => developmentHistory.posLevel) developmentHistorys: DevelopmentHistory[]; } export class CreatePosLevel { @Column() posLevelName: string; @Column() posLevelRank: number; @Column() posLevelAuthority: string; @Column("uuid") posTypeId: string; } export type UpdatePosLevel = Partial & { posLevelAuthority?: PosLevelAuthority };