2025-02-20 13:29:29 +07:00
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 ( )
2025-03-14 15:17:32 +07:00
posMasterNoPrefix? : string | null ;
2025-02-20 13:29:29 +07:00
@Column ( )
2025-03-14 15:17:32 +07:00
posMasterNo? : number | null ;
2025-02-20 13:29:29 +07:00
@Column ( )
2025-03-14 15:17:32 +07:00
posMasterNoSuffix? : string | null ;
2025-02-20 13:29:29 +07:00
@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 > ;