เพิ่ม entity [PosType ,PosExecutive ,PosLevel]

This commit is contained in:
AdisakKanthawilang 2024-01-30 10:59:49 +07:00
parent 33967dcd7c
commit c72dbe5fb0
3 changed files with 89 additions and 0 deletions

View file

@ -0,0 +1,19 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
@Entity("posExecutive")
export class PosExecutive extends EntityBase {
@Column({
nullable: true,
comment: "ชื่อตำแหน่งทางการบริหาร",
length: 255,
default: "string",
})
posExecutiveName: string;
@Column({
nullable: true,
comment: "ลำดับความสำคัญ",
})
posExecutivePriority: number;
}

46
src/entities/PosLevel.ts Normal file
View file

@ -0,0 +1,46 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { PosType } from "./PosType";
// ENUM PosLevelAuthority
enum PosLevelAuthority {
HEAD = "HEAD",
DEPUTY = "DEPUTY",
GOVERNOR = "GOVERNOR",
}
@Entity("posLevel")
export class PosLevel extends EntityBase {
@Column({
nullable: true,
comment: "ชื่อระดับตำแหน่ง",
type: "tinytext",
default: "string",
})
posLevelName: string;
@Column({
nullable: true,
comment: "ระดับของระดับตำแหน่ง",
})
posLevelRank: number;
@Column({
nullable: true,
comment:
"ผู้มีอำนาจสั่งบรรจุของระดับนี้ head = หัวหน้าหน่วยงาน , deputy = ปลัด , governor = ผู้ว่าฯ",
type: "enum",
enum: PosLevelAuthority,
})
posLevelAuthority: PosLevelAuthority;
@Column({
length: 40,
comment: "เป็นระดับของประเภทตำแหน่งใด",
default: "00000000-0000-0000-0000-000000000000",
})
posTypeId: string;
@ManyToOne(() => PosType, (posType) => posType.posLevels)
@JoinColumn({ name: "posTypeId" })
posType: PosType;
}

24
src/entities/PosType.ts Normal file
View file

@ -0,0 +1,24 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { PosLevel } from "./PosLevel";
@Entity("posType")
export class PosType extends EntityBase {
@Column({
nullable: true,
comment: "ชื่อประเภทตำแหน่ง (ทั่วไป วิชาการ อำนวยการ บริหาร)",
type: "tinytext",
default: "string",
})
posTypeName: string;
@Column({
nullable: true,
comment: "ระดับของประเภทตำแหน่ง ไว้ใช้ระบุว่าประเภทตำแหน่งนี้อยู่ระดับสูงหรือต่ำกว่ากัน โดย 1 = ต่ำกว่า , มากกว่า 1 = สูงกว่า ทั่วไป = 1 วิชาการ = 2 อำนวยการ = 3 บริหาร = 4",
})
posTypeRank: number;
@OneToMany(() => PosLevel, (posLevel) => posLevel.posType)
posLevels: PosLevel[];
}