add posmaster temp
This commit is contained in:
parent
fc397ed22d
commit
b369a52734
13 changed files with 2751 additions and 6 deletions
2357
src/controllers/EmployeeTempPositionController.ts
Normal file
2357
src/controllers/EmployeeTempPositionController.ts
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -3,6 +3,7 @@ import { EntityBase } from "./base/Base";
|
|||
import { AuthRoleAttr } from "./AuthRoleAttr";
|
||||
import { PosMaster } from "./PosMaster";
|
||||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||
import { EmployeeTempPosMaster } from "./EmployeeTempPosMaster";
|
||||
|
||||
@Entity("authRole")
|
||||
export class AuthRole extends EntityBase {
|
||||
|
|
@ -30,6 +31,9 @@ export class AuthRole extends EntityBase {
|
|||
|
||||
@OneToMany(() => EmployeePosMaster, (posMasters) => posMasters.authRole)
|
||||
posMasterEmps: EmployeePosMaster[];
|
||||
|
||||
@OneToMany(() => EmployeeTempPosMaster, (posMasters) => posMasters.authRole)
|
||||
posMasterEmpTemps: EmployeeTempPosMaster[];
|
||||
}
|
||||
|
||||
export class CreateAuthRole {
|
||||
|
|
|
|||
|
|
@ -197,27 +197,27 @@ export class EmployeePosMaster extends EntityBase {
|
|||
@JoinColumn({ name: "authRoleId" })
|
||||
authRole: AuthRole;
|
||||
|
||||
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.posMasters)
|
||||
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.employeePosMasters)
|
||||
@JoinColumn({ name: "orgRevisionId" })
|
||||
orgRevision: OrgRevision;
|
||||
|
||||
@ManyToOne(() => OrgRoot, (orgRoot) => orgRoot.posMasters)
|
||||
@ManyToOne(() => OrgRoot, (orgRoot) => orgRoot.employeePosMasters)
|
||||
@JoinColumn({ name: "orgRootId" })
|
||||
orgRoot: OrgRoot;
|
||||
|
||||
@ManyToOne(() => OrgChild1, (orgChild1) => orgChild1.posMasters)
|
||||
@ManyToOne(() => OrgChild1, (orgChild1) => orgChild1.employeePosMasters)
|
||||
@JoinColumn({ name: "orgChild1Id" })
|
||||
orgChild1: OrgChild1;
|
||||
|
||||
@ManyToOne(() => OrgChild2, (orgChild2) => orgChild2.posMasters)
|
||||
@ManyToOne(() => OrgChild2, (orgChild2) => orgChild2.employeePosMasters)
|
||||
@JoinColumn({ name: "orgChild2Id" })
|
||||
orgChild2: OrgChild2;
|
||||
|
||||
@ManyToOne(() => OrgChild3, (orgChild3) => orgChild3.posMasters)
|
||||
@ManyToOne(() => OrgChild3, (orgChild3) => orgChild3.employeePosMasters)
|
||||
@JoinColumn({ name: "orgChild3Id" })
|
||||
orgChild3: OrgChild3;
|
||||
|
||||
@ManyToOne(() => OrgChild4, (orgChild4) => orgChild4.posMasters)
|
||||
@ManyToOne(() => OrgChild4, (orgChild4) => orgChild4.employeePosMasters)
|
||||
@JoinColumn({ name: "orgChild4Id" })
|
||||
orgChild4: OrgChild4;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { EntityBase } from "./base/Base";
|
|||
import { EmployeePosType } from "./EmployeePosType";
|
||||
import { EmployeePosLevel } from "./EmployeePosLevel";
|
||||
import { EmployeePosMaster } from "./EmployeePosMaster";
|
||||
import { EmployeeTempPosMaster } from "./EmployeeTempPosMaster";
|
||||
|
||||
@Entity("employeePosition")
|
||||
export class EmployeePosition extends EntityBase {
|
||||
|
|
@ -38,10 +39,20 @@ export class EmployeePosition extends EntityBase {
|
|||
})
|
||||
posMasterId: string;
|
||||
|
||||
@Column({
|
||||
length: 40,
|
||||
comment: "เชื่อมโยงกับตารางเลขที่ตำแหน่ง",
|
||||
})
|
||||
posMasterTempId: string;
|
||||
|
||||
@ManyToOne(() => EmployeePosMaster, (posMaster) => posMaster)
|
||||
@JoinColumn({ name: "posMasterId" })
|
||||
posMaster: EmployeePosMaster;
|
||||
|
||||
@ManyToOne(() => EmployeePosMaster, (posMaster) => posMaster)
|
||||
@JoinColumn({ name: "posMasterTempId" })
|
||||
posMasterTemp: EmployeeTempPosMaster;
|
||||
|
||||
@ManyToOne(() => EmployeePosType, (posType) => posType)
|
||||
@JoinColumn({ name: "posTypeId" })
|
||||
posType: EmployeePosType;
|
||||
|
|
|
|||
271
src/entities/EmployeeTempPosMaster.ts
Normal file
271
src/entities/EmployeeTempPosMaster.ts
Normal file
|
|
@ -0,0 +1,271 @@
|
|||
import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
|
||||
import { EntityBase } from "./base/Base";
|
||||
import { CreateEmployeePosDict } from "./EmployeePosDict";
|
||||
import { OrgRevision } from "./OrgRevision";
|
||||
import { EmployeePosition } from "./EmployeePosition";
|
||||
import { OrgRoot } from "./OrgRoot";
|
||||
import { OrgChild1 } from "./OrgChild1";
|
||||
import { OrgChild2 } from "./OrgChild2";
|
||||
import { OrgChild3 } from "./OrgChild3";
|
||||
import { OrgChild4 } from "./OrgChild4";
|
||||
import { ProfileEmployee } from "./ProfileEmployee";
|
||||
import { AuthRole } from "./AuthRole";
|
||||
|
||||
enum EmployeeTempPosMasterLine {
|
||||
MAIN = "MAIN",
|
||||
SUPPORT = "SUPPORT",
|
||||
}
|
||||
|
||||
@Entity("employeeTempPosMaster")
|
||||
export class EmployeeTempPosMaster extends EntityBase {
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ)",
|
||||
length: 16,
|
||||
default: null,
|
||||
})
|
||||
posMasterNoPrefix: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "เลขที่ตำแหน่ง เป็นตัวเลข",
|
||||
default: null,
|
||||
})
|
||||
posMasterNo: number;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "Suffix หลังเลขที่ตำแหน่ง เช่น ช.",
|
||||
length: 16,
|
||||
default: null,
|
||||
})
|
||||
posMasterNoSuffix: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: "datetime",
|
||||
comment: "วัน-เวลาที่สร้าง",
|
||||
default: null,
|
||||
})
|
||||
posMasterCreatedAt: Date;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment:
|
||||
"รหัส DNA ใช้ในกรณีที่มีการทำสำเนาโครงสร้างและตำแหน่ง ตำแหน่งที่ทำสำเนามากับตำแหน่งเก่าจะต้องมี DNA เดียวกัน เพื่อให้ track ประวัติการแก้ไขตำแหน่งย้อนหลังได้",
|
||||
length: 40,
|
||||
default: null,
|
||||
})
|
||||
ancestorDNA: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ลำดับที่แสดงผล",
|
||||
default: null,
|
||||
})
|
||||
posMasterOrder: number;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ลำดับความสำคัญ",
|
||||
default: null,
|
||||
})
|
||||
posMasterPriority: number;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "สายงานในอัตรากำลัง (หลัก / สนับสนุน) คนละฟิลด์กับสายงานของตำแหน่ง",
|
||||
type: "enum",
|
||||
enum: EmployeeTempPosMasterLine,
|
||||
default: null,
|
||||
})
|
||||
posMasterLine: EmployeeTempPosMasterLine;
|
||||
|
||||
@Column({
|
||||
comment: "นั่งทับตำแหน่งไหม",
|
||||
default: false,
|
||||
})
|
||||
isSit: boolean;
|
||||
|
||||
@Column({
|
||||
comment: "เป็นผู้อำนวยการ",
|
||||
default: false,
|
||||
})
|
||||
isDirector: boolean;
|
||||
|
||||
@Column({
|
||||
comment: "เป็นเจ้าหน้าที่",
|
||||
default: false,
|
||||
})
|
||||
isStaff: boolean;
|
||||
|
||||
// @Column({
|
||||
// comment: "เป็นสกจ",
|
||||
// default: false,
|
||||
// })
|
||||
// isOfficer: boolean;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ตำแหน่งใต้ลายเซ็นต์",
|
||||
type: "text",
|
||||
default: null,
|
||||
})
|
||||
positionSign: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "หมายเหตุ",
|
||||
type: "text",
|
||||
default: null,
|
||||
})
|
||||
reason: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment: "คีย์นอก(FK)ของตาราง orgRoot",
|
||||
default: null,
|
||||
})
|
||||
orgRootId?: string | null;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment: "คีย์นอก(FK)ของตาราง orgChild1",
|
||||
default: null,
|
||||
})
|
||||
orgChild1Id?: string | null;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment: "คีย์นอก(FK)ของตาราง orgChild2",
|
||||
default: null,
|
||||
})
|
||||
orgChild2Id?: string | null;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment: "คีย์นอก(FK)ของตาราง orgChild3",
|
||||
default: null,
|
||||
})
|
||||
orgChild3Id?: string | null;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment: "คีย์นอก(FK)ของตาราง orgChild4",
|
||||
default: null,
|
||||
})
|
||||
orgChild4Id?: string | null;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment:
|
||||
"คนครองปัจจุบัน เมื่อทำสำเนาโครงสร้างและตำแหน่งพร้อมกับคนครองมา คนครองจะอยู่ในฟิลด์นี้",
|
||||
default: null,
|
||||
})
|
||||
current_holderId?: string | null;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment:
|
||||
"คนที่กำลังจะมาครอง ตอนปรับโครงสร้าง ถ้าเลือกให้ใครมาครอง ProfileId ของคนนั้นจะมาอยู่ในช่องนี้ รวมทั้งตอนเลือกตำแหน่งเพื่อบรรจุ แต่งตั้ง เลื่อน ย้าย ในระบบบรรจุแต่งตั้งด้วย",
|
||||
default: null,
|
||||
})
|
||||
next_holderId?: string | null;
|
||||
|
||||
@Column({
|
||||
length: 40,
|
||||
comment: "คีย์นอก(FK)ของตาราง orgRevision",
|
||||
})
|
||||
orgRevisionId: string; //fk
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
default: null,
|
||||
length: 40,
|
||||
comment: "คีย์นอก(FK)ของตาราง authRole",
|
||||
})
|
||||
authRoleId: string;
|
||||
|
||||
@ManyToOne(() => AuthRole, (authRole) => authRole.posMasterEmpTemps)
|
||||
@JoinColumn({ name: "authRoleId" })
|
||||
authRole: AuthRole;
|
||||
|
||||
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.employeeTempPosMasters)
|
||||
@JoinColumn({ name: "orgRevisionId" })
|
||||
orgRevision: OrgRevision;
|
||||
|
||||
@ManyToOne(() => OrgRoot, (orgRoot) => orgRoot.employeeTempPosMasters)
|
||||
@JoinColumn({ name: "orgRootId" })
|
||||
orgRoot: OrgRoot;
|
||||
|
||||
@ManyToOne(() => OrgChild1, (orgChild1) => orgChild1.employeeTempPosMasters)
|
||||
@JoinColumn({ name: "orgChild1Id" })
|
||||
orgChild1: OrgChild1;
|
||||
|
||||
@ManyToOne(() => OrgChild2, (orgChild2) => orgChild2.employeeTempPosMasters)
|
||||
@JoinColumn({ name: "orgChild2Id" })
|
||||
orgChild2: OrgChild2;
|
||||
|
||||
@ManyToOne(() => OrgChild3, (orgChild3) => orgChild3.employeeTempPosMasters)
|
||||
@JoinColumn({ name: "orgChild3Id" })
|
||||
orgChild3: OrgChild3;
|
||||
|
||||
@ManyToOne(() => OrgChild4, (orgChild4) => orgChild4.employeeTempPosMasters)
|
||||
@JoinColumn({ name: "orgChild4Id" })
|
||||
orgChild4: OrgChild4;
|
||||
|
||||
@ManyToOne(() => ProfileEmployee, (posMaster) => posMaster.current_holderTemps)
|
||||
@JoinColumn({ name: "current_holderId" })
|
||||
current_holder: ProfileEmployee;
|
||||
|
||||
@ManyToOne(() => ProfileEmployee, (posMaster) => posMaster.next_holderTemps)
|
||||
@JoinColumn({ name: "next_holderId" })
|
||||
next_holder: ProfileEmployee;
|
||||
|
||||
@OneToMany(() => EmployeePosition, (position) => position.posMasterTemp)
|
||||
positions: EmployeePosition[];
|
||||
}
|
||||
|
||||
export class CreateEmployeeTempPosMaster {
|
||||
@Column()
|
||||
posMasterNoPrefix: string;
|
||||
|
||||
@Column()
|
||||
posMasterNo: number;
|
||||
|
||||
@Column()
|
||||
posMasterNoSuffix: string;
|
||||
|
||||
@Column("uuid")
|
||||
positions: CreateEmployeePosDict[];
|
||||
|
||||
@Column("uuid")
|
||||
orgRootId?: string | null;
|
||||
|
||||
@Column("uuid")
|
||||
orgChild1Id?: string | null;
|
||||
|
||||
@Column("uuid")
|
||||
orgChild2Id?: string | null;
|
||||
|
||||
@Column("uuid")
|
||||
orgChild3Id?: string | null;
|
||||
|
||||
@Column("uuid")
|
||||
orgChild4Id?: string | null;
|
||||
|
||||
@Column()
|
||||
reason: string | null;
|
||||
|
||||
@Column()
|
||||
isDirector: boolean;
|
||||
}
|
||||
|
||||
export type UpdateEmployeeTempPosMaster = Partial<EmployeeTempPosMaster>;
|
||||
|
|
@ -6,6 +6,8 @@ import { OrgRevision } from "./OrgRevision";
|
|||
import { OrgChild3 } from "./OrgChild3";
|
||||
import { OrgChild4 } from "./OrgChild4";
|
||||
import { PosMaster } from "./PosMaster";
|
||||
import { EmployeePosMaster } from "./EmployeePosMaster";
|
||||
import { EmployeeTempPosMaster } from "./EmployeeTempPosMaster";
|
||||
|
||||
enum OrgChild1Rank {
|
||||
DEPARTMENT = "DEPARTMENT",
|
||||
|
|
@ -187,6 +189,15 @@ export class OrgChild1 extends EntityBase {
|
|||
|
||||
@OneToMany(() => PosMaster, (posMaster) => posMaster.orgChild1)
|
||||
posMasters: PosMaster[];
|
||||
|
||||
@OneToMany(() => EmployeePosMaster, (employeePosMaster) => employeePosMaster.orgChild1)
|
||||
employeePosMasters: EmployeePosMaster[];
|
||||
|
||||
@OneToMany(
|
||||
() => EmployeeTempPosMaster,
|
||||
(employeeTempposMaster) => employeeTempposMaster.orgChild1,
|
||||
)
|
||||
employeeTempPosMasters: EmployeeTempPosMaster[];
|
||||
}
|
||||
|
||||
export class CreateOrgChild1 {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import { OrgChild3 } from "./OrgChild3";
|
|||
import { OrgChild4 } from "./OrgChild4";
|
||||
import { OrgRevision } from "./OrgRevision";
|
||||
import { PosMaster } from "./PosMaster";
|
||||
import { EmployeePosMaster } from "./EmployeePosMaster";
|
||||
import { EmployeeTempPosMaster } from "./EmployeeTempPosMaster";
|
||||
|
||||
enum OrgChild2Rank {
|
||||
DEPARTMENT = "DEPARTMENT",
|
||||
|
|
@ -181,6 +183,15 @@ export class OrgChild2 extends EntityBase {
|
|||
|
||||
@OneToMany(() => PosMaster, (posMaster) => posMaster.orgChild2)
|
||||
posMasters: PosMaster[];
|
||||
|
||||
@OneToMany(() => EmployeePosMaster, (employeePosMaster) => employeePosMaster.orgChild2)
|
||||
employeePosMasters: EmployeePosMaster[];
|
||||
|
||||
@OneToMany(
|
||||
() => EmployeeTempPosMaster,
|
||||
(employeeTempposMaster) => employeeTempposMaster.orgChild2,
|
||||
)
|
||||
employeeTempPosMasters: EmployeeTempPosMaster[];
|
||||
}
|
||||
|
||||
export class CreateOrgChild2 {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import { OrgRevision } from "./OrgRevision";
|
|||
import { OrgChild1 } from "./OrgChild1";
|
||||
import { OrgRoot } from "./OrgRoot";
|
||||
import { PosMaster } from "./PosMaster";
|
||||
import { EmployeePosMaster } from "./EmployeePosMaster";
|
||||
import { EmployeeTempPosMaster } from "./EmployeeTempPosMaster";
|
||||
|
||||
enum OrgChild3Rank {
|
||||
DEPARTMENT = "DEPARTMENT",
|
||||
|
|
@ -189,6 +191,15 @@ export class OrgChild3 extends EntityBase {
|
|||
|
||||
@OneToMany(() => PosMaster, (posMaster) => posMaster.orgChild3)
|
||||
posMasters: PosMaster[];
|
||||
|
||||
@OneToMany(() => EmployeePosMaster, (employeePosMaster) => employeePosMaster.orgChild3)
|
||||
employeePosMasters: EmployeePosMaster[];
|
||||
|
||||
@OneToMany(
|
||||
() => EmployeeTempPosMaster,
|
||||
(employeeTempposMaster) => employeeTempposMaster.orgChild3,
|
||||
)
|
||||
employeeTempPosMasters: EmployeeTempPosMaster[];
|
||||
}
|
||||
|
||||
export class CreateOrgChild3 {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import { OrgChild2 } from "./OrgChild2";
|
|||
import { OrgChild3 } from "./OrgChild3";
|
||||
import { OrgRevision } from "./OrgRevision";
|
||||
import { PosMaster } from "./PosMaster";
|
||||
import { EmployeePosMaster } from "./EmployeePosMaster";
|
||||
import { EmployeeTempPosMaster } from "./EmployeeTempPosMaster";
|
||||
|
||||
enum OrgChild4Rank {
|
||||
DEPARTMENT = "DEPARTMENT",
|
||||
|
|
@ -195,6 +197,15 @@ export class OrgChild4 extends EntityBase {
|
|||
|
||||
@OneToMany(() => PosMaster, (posMaster) => posMaster.orgChild4)
|
||||
posMasters: PosMaster[];
|
||||
|
||||
@OneToMany(() => EmployeePosMaster, (employeePosMaster) => employeePosMaster.orgChild4)
|
||||
employeePosMasters: EmployeePosMaster[];
|
||||
|
||||
@OneToMany(
|
||||
() => EmployeeTempPosMaster,
|
||||
(employeeTempposMaster) => employeeTempposMaster.orgChild4,
|
||||
)
|
||||
employeeTempPosMasters: EmployeeTempPosMaster[];
|
||||
}
|
||||
|
||||
export class CreateOrgChild4 {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { OrgChild2 } from "./OrgChild2";
|
|||
import { OrgChild3 } from "./OrgChild3";
|
||||
import { OrgChild4 } from "./OrgChild4";
|
||||
import { EmployeePosMaster } from "./EmployeePosMaster";
|
||||
import { EmployeeTempPosMaster } from "./EmployeeTempPosMaster";
|
||||
|
||||
@Entity("orgRevision")
|
||||
export class OrgRevision extends EntityBase {
|
||||
|
|
@ -65,6 +66,12 @@ export class OrgRevision extends EntityBase {
|
|||
@OneToMany(() => EmployeePosMaster, (employeePosMaster) => employeePosMaster.orgRevision)
|
||||
employeePosMasters: EmployeePosMaster[];
|
||||
|
||||
@OneToMany(
|
||||
() => EmployeeTempPosMaster,
|
||||
(employeeTempPosMaster) => employeeTempPosMaster.orgRevision,
|
||||
)
|
||||
employeeTempPosMasters: EmployeeTempPosMaster[];
|
||||
|
||||
@OneToMany(() => OrgRoot, (orgRoot) => orgRoot.orgRevision)
|
||||
orgRoots: OrgRoot[];
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import { OrgChild3 } from "./OrgChild3";
|
|||
import { OrgChild4 } from "./OrgChild4";
|
||||
import { PosMaster } from "./PosMaster";
|
||||
import { PermissionOrg } from "./PermissionOrg";
|
||||
import { EmployeePosMaster } from "./EmployeePosMaster";
|
||||
import { EmployeeTempPosMaster } from "./EmployeeTempPosMaster";
|
||||
|
||||
enum OrgRootRank {
|
||||
DEPARTMENT = "DEPARTMENT",
|
||||
|
|
@ -170,6 +172,12 @@ export class OrgRoot extends EntityBase {
|
|||
@OneToMany(() => PosMaster, (posMaster) => posMaster.orgRoot)
|
||||
posMasters: PosMaster[];
|
||||
|
||||
@OneToMany(() => EmployeePosMaster, (employeePosMaster) => employeePosMaster.orgRoot)
|
||||
employeePosMasters: EmployeePosMaster[];
|
||||
|
||||
@OneToMany(() => EmployeeTempPosMaster, (employeeTempposMaster) => employeeTempposMaster.orgRoot)
|
||||
employeeTempPosMasters: EmployeeTempPosMaster[];
|
||||
|
||||
@OneToMany(() => OrgChild1, (orgChild1) => orgChild1.orgRoot)
|
||||
orgChild1s: OrgChild1[];
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import { ProfileDevelopment } from "./ProfileDevelopment";
|
|||
import { DevelopmentRequest } from "./DevelopmentRequest";
|
||||
import { RoleKeycloak } from "./RoleKeycloak";
|
||||
import { StateOperatorUser } from "./StateOperatorUser";
|
||||
import { EmployeeTempPosMaster } from "./EmployeeTempPosMaster";
|
||||
|
||||
@Entity("profileEmployee")
|
||||
export class ProfileEmployee extends EntityBase {
|
||||
|
|
@ -674,6 +675,12 @@ export class ProfileEmployee extends EntityBase {
|
|||
@OneToMany(() => EmployeePosMaster, (v) => v.next_holder)
|
||||
next_holders: EmployeePosMaster[];
|
||||
|
||||
@OneToMany(() => EmployeeTempPosMaster, (v) => v.current_holder)
|
||||
current_holderTemps: EmployeeTempPosMaster[];
|
||||
|
||||
@OneToMany(() => EmployeeTempPosMaster, (v) => v.next_holder)
|
||||
next_holderTemps: EmployeeTempPosMaster[];
|
||||
|
||||
@OneToMany(() => ProfileSalary, (v) => v.profileEmployee)
|
||||
profileSalary: ProfileSalary[];
|
||||
|
||||
|
|
|
|||
36
src/migration/1740032788782-addtableorgtemp.ts
Normal file
36
src/migration/1740032788782-addtableorgtemp.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class Addtableorgtemp1740032788782 implements MigrationInterface {
|
||||
name = 'Addtableorgtemp1740032788782'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`CREATE TABLE \`employeeTempPosMaster\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`posMasterNoPrefix\` varchar(16) NULL COMMENT 'Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ)', \`posMasterNo\` int NULL COMMENT 'เลขที่ตำแหน่ง เป็นตัวเลข', \`posMasterNoSuffix\` varchar(16) NULL COMMENT 'Suffix หลังเลขที่ตำแหน่ง เช่น ช.', \`posMasterCreatedAt\` datetime NULL COMMENT 'วัน-เวลาที่สร้าง', \`ancestorDNA\` varchar(40) NULL COMMENT 'รหัส DNA ใช้ในกรณีที่มีการทำสำเนาโครงสร้างและตำแหน่ง ตำแหน่งที่ทำสำเนามากับตำแหน่งเก่าจะต้องมี DNA เดียวกัน เพื่อให้ track ประวัติการแก้ไขตำแหน่งย้อนหลังได้', \`posMasterOrder\` int NULL COMMENT 'ลำดับที่แสดงผล', \`posMasterPriority\` int NULL COMMENT 'ลำดับความสำคัญ', \`posMasterLine\` enum ('MAIN', 'SUPPORT') NULL COMMENT 'สายงานในอัตรากำลัง (หลัก / สนับสนุน) คนละฟิลด์กับสายงานของตำแหน่ง', \`isSit\` tinyint NOT NULL COMMENT 'นั่งทับตำแหน่งไหม' DEFAULT 0, \`isDirector\` tinyint NOT NULL COMMENT 'เป็นผู้อำนวยการ' DEFAULT 0, \`isStaff\` tinyint NOT NULL COMMENT 'เป็นเจ้าหน้าที่' DEFAULT 0, \`positionSign\` text NULL COMMENT 'ตำแหน่งใต้ลายเซ็นต์', \`reason\` text NULL COMMENT 'หมายเหตุ', \`orgRootId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง orgRoot', \`orgChild1Id\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง orgChild1', \`orgChild2Id\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง orgChild2', \`orgChild3Id\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง orgChild3', \`orgChild4Id\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง orgChild4', \`current_holderId\` varchar(40) NULL COMMENT 'คนครองปัจจุบัน เมื่อทำสำเนาโครงสร้างและตำแหน่งพร้อมกับคนครองมา คนครองจะอยู่ในฟิลด์นี้', \`next_holderId\` varchar(40) NULL COMMENT 'คนที่กำลังจะมาครอง ตอนปรับโครงสร้าง ถ้าเลือกให้ใครมาครอง ProfileId ของคนนั้นจะมาอยู่ในช่องนี้ รวมทั้งตอนเลือกตำแหน่งเพื่อบรรจุ แต่งตั้ง เลื่อน ย้าย ในระบบบรรจุแต่งตั้งด้วย', \`orgRevisionId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง orgRevision', \`authRoleId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง authRole', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`ALTER TABLE \`employeePosition\` ADD \`posMasterTempId\` varchar(40) NOT NULL COMMENT 'เชื่อมโยงกับตารางเลขที่ตำแหน่ง'`);
|
||||
await queryRunner.query(`ALTER TABLE \`employeeTempPosMaster\` ADD CONSTRAINT \`FK_fbdaed7e18a082ec271453c3af3\` FOREIGN KEY (\`authRoleId\`) REFERENCES \`authRole\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`employeeTempPosMaster\` ADD CONSTRAINT \`FK_6882777277ba389e6d87251451e\` FOREIGN KEY (\`orgRevisionId\`) REFERENCES \`orgRevision\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`employeeTempPosMaster\` ADD CONSTRAINT \`FK_4ea59a95b75b76d9fecf18b3329\` FOREIGN KEY (\`orgRootId\`) REFERENCES \`orgRoot\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`employeeTempPosMaster\` ADD CONSTRAINT \`FK_d5df44e2dfbfb67f9303ef53664\` FOREIGN KEY (\`orgChild1Id\`) REFERENCES \`orgChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`employeeTempPosMaster\` ADD CONSTRAINT \`FK_507c4ec071a564b871018afd99f\` FOREIGN KEY (\`orgChild2Id\`) REFERENCES \`orgChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`employeeTempPosMaster\` ADD CONSTRAINT \`FK_50eb54a5cda9103e1ca5b28fbc7\` FOREIGN KEY (\`orgChild3Id\`) REFERENCES \`orgChild3\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`employeeTempPosMaster\` ADD CONSTRAINT \`FK_099675941952365232292ee5b79\` FOREIGN KEY (\`orgChild4Id\`) REFERENCES \`orgChild4\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`employeeTempPosMaster\` ADD CONSTRAINT \`FK_2544a0337043dd5a593b1698336\` FOREIGN KEY (\`current_holderId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`employeeTempPosMaster\` ADD CONSTRAINT \`FK_d7e32a7900d32a7358d64464a91\` FOREIGN KEY (\`next_holderId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`employeePosition\` ADD CONSTRAINT \`FK_d98cc02c1c2f9830afcb1493b00\` FOREIGN KEY (\`posMasterTempId\`) REFERENCES \`employeePosMaster\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`employeePosition\` DROP FOREIGN KEY \`FK_d98cc02c1c2f9830afcb1493b00\``);
|
||||
await queryRunner.query(`ALTER TABLE \`employeeTempPosMaster\` DROP FOREIGN KEY \`FK_d7e32a7900d32a7358d64464a91\``);
|
||||
await queryRunner.query(`ALTER TABLE \`employeeTempPosMaster\` DROP FOREIGN KEY \`FK_2544a0337043dd5a593b1698336\``);
|
||||
await queryRunner.query(`ALTER TABLE \`employeeTempPosMaster\` DROP FOREIGN KEY \`FK_099675941952365232292ee5b79\``);
|
||||
await queryRunner.query(`ALTER TABLE \`employeeTempPosMaster\` DROP FOREIGN KEY \`FK_50eb54a5cda9103e1ca5b28fbc7\``);
|
||||
await queryRunner.query(`ALTER TABLE \`employeeTempPosMaster\` DROP FOREIGN KEY \`FK_507c4ec071a564b871018afd99f\``);
|
||||
await queryRunner.query(`ALTER TABLE \`employeeTempPosMaster\` DROP FOREIGN KEY \`FK_d5df44e2dfbfb67f9303ef53664\``);
|
||||
await queryRunner.query(`ALTER TABLE \`employeeTempPosMaster\` DROP FOREIGN KEY \`FK_4ea59a95b75b76d9fecf18b3329\``);
|
||||
await queryRunner.query(`ALTER TABLE \`employeeTempPosMaster\` DROP FOREIGN KEY \`FK_6882777277ba389e6d87251451e\``);
|
||||
await queryRunner.query(`ALTER TABLE \`employeeTempPosMaster\` DROP FOREIGN KEY \`FK_fbdaed7e18a082ec271453c3af3\``);
|
||||
await queryRunner.query(`ALTER TABLE \`employeePosition\` DROP COLUMN \`posMasterTempId\``);
|
||||
await queryRunner.query(`DROP TABLE \`employeeTempPosMaster\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue