2024-10-18 11:52:35 +07:00
import { Entity , Column , ManyToOne , JoinColumn , OneToMany } from "typeorm" ;
2024-01-24 16:08:34 +07:00
import { EntityBase } from "./base/Base" ;
import { OrgChild1 } from "./OrgChild1" ;
2024-01-26 15:54:07 +07:00
import { OrgRevision } from "./OrgRevision" ;
2024-01-31 14:29:39 +07:00
import { OrgChild2 } from "./OrgChild2" ;
import { OrgChild3 } from "./OrgChild3" ;
import { OrgChild4 } from "./OrgChild4" ;
2024-01-31 15:31:20 +07:00
import { PosMaster } from "./PosMaster" ;
2024-09-06 09:41:47 +07:00
import { PermissionOrg } from "./PermissionOrg" ;
2024-01-24 16:08:34 +07:00
enum OrgRootRank {
2024-01-26 10:13:07 +07:00
DEPARTMENT = "DEPARTMENT" ,
OFFICE = "OFFICE" ,
DIVISION = "DIVISION" ,
SECTION = "SECTION" ,
2024-01-24 16:08:34 +07:00
}
@Entity ( "orgRoot" )
export class OrgRoot extends EntityBase {
2025-01-17 16:11:30 +07:00
@Column ( {
nullable : true ,
comment : "MisId" ,
length : 255 ,
default : null ,
} )
misId : string ;
2024-01-24 16:08:34 +07:00
@Column ( {
nullable : true ,
comment : "ชื่อหน่วยงาน" ,
length : 255 ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-24 16:08:34 +07:00
} )
orgRootName : string ;
@Column ( {
nullable : true ,
comment : "ชื่อย่อหน่วยงาน" ,
length : 16 ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-24 16:08:34 +07:00
} )
orgRootShortName : string ;
@Column ( {
nullable : true ,
comment : "รหัสหน่วยงาน" ,
length : 8 ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-24 16:08:34 +07:00
} )
orgRootCode : string ;
@Column ( {
nullable : true ,
comment : "ระดับของหน่วยงาน" ,
type : "enum" ,
enum : OrgRootRank ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-24 16:08:34 +07:00
} )
orgRootRank : OrgRootRank ;
2024-03-13 09:47:19 +07:00
@Column ( {
nullable : true ,
comment : "ระดับส่วนราชการsub" ,
default : null ,
} )
orgRootRankSub : string ;
2024-01-24 16:08:34 +07:00
@Column ( {
nullable : true ,
comment : "ลำดับที่ของหน่วยงาน" ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-24 16:08:34 +07:00
} )
orgRootOrder : number ;
@Column ( {
nullable : true ,
length : 64 ,
comment : "หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก" ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-24 16:08:34 +07:00
} )
orgRootPhoneEx : string ;
@Column ( {
nullable : true ,
length : 64 ,
comment : "หมายเลขโทรศัพท์ที่ติดต่อจากภายใน" ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-24 16:08:34 +07:00
} )
orgRootPhoneIn : string ;
@Column ( {
nullable : true ,
length : 64 ,
comment : "หมายเลขโทรสาร" ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-24 16:08:34 +07:00
} )
orgRootFax : string ;
@Column ( {
2024-02-01 11:02:35 +07:00
nullable : true ,
2024-01-24 16:08:34 +07:00
length : 40 ,
2024-03-13 09:47:19 +07:00
comment :
"รหัส DNA ใช้ในกรณีที่มีการทำสำเนาโครงสร้าง โครงสร้างใหม่ที่ทำสำเนากับโครงสร้างเก่าจะต้องมี DNA เดียวกัน เพื่อให้ track ประวัติการแก้ไขโครงสร้างย้อนหลังได้" ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-24 16:08:34 +07:00
} )
2024-02-01 13:29:15 +07:00
ancestorDNA : string ;
2024-01-24 16:08:34 +07:00
2024-05-14 11:55:00 +07:00
@Column ( {
nullable : true ,
length : 255 ,
2024-05-14 14:37:23 +07:00
comment : "หน้าที่ความรับผิดชอบ" ,
2024-05-14 11:55:00 +07:00
default : null ,
} )
2024-05-14 15:29:05 +07:00
responsibility : string ;
2024-05-14 11:55:00 +07:00
2024-10-21 17:11:21 +07:00
@Column ( {
comment : "เป็นปลัด" ,
default : false ,
} )
isDeputy : boolean ;
2025-01-20 15:14:00 +07:00
@Column ( {
comment : "สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร" ,
default : false ,
} )
isCommission : boolean ;
2024-01-26 09:56:27 +07:00
@Column ( {
length : 40 ,
2024-02-01 14:17:56 +07:00
comment : "คีย์นอก(FK)ของตาราง orgRevision" ,
2024-01-26 09:56:27 +07:00
} )
2024-01-26 20:25:18 +07:00
orgRevisionId : string ;
2025-02-10 12:07:09 +07:00
@Column ( {
nullable : true ,
length : 5 ,
comment : "DEPARTMENT_CODE" ,
default : null ,
} )
DEPARTMENT_CODE : string ;
@Column ( {
nullable : true ,
length : 5 ,
comment : "DIVISION_CODE" ,
default : null ,
} )
DIVISION_CODE : string ;
@Column ( {
nullable : true ,
length : 5 ,
comment : "SECTION_CODE" ,
default : null ,
} )
SECTION_CODE : string ;
@Column ( {
nullable : true ,
length : 5 ,
comment : "JOB_CODE" ,
default : null ,
} )
JOB_CODE : string ;
2024-01-26 20:25:18 +07:00
@ManyToOne ( ( ) = > OrgRevision , ( orgRevision ) = > orgRevision . orgRoots )
2024-01-26 15:54:07 +07:00
@JoinColumn ( { name : "orgRevisionId" } )
orgRevision : OrgRevision ;
2024-01-26 20:25:18 +07:00
2024-01-31 15:31:20 +07:00
@OneToMany ( ( ) = > PosMaster , ( posMaster ) = > posMaster . orgRoot )
posMasters : PosMaster [ ] ;
2024-01-25 14:35:19 +07:00
@OneToMany ( ( ) = > OrgChild1 , ( orgChild1 ) = > orgChild1 . orgRoot )
2024-01-24 16:08:34 +07:00
orgChild1s : OrgChild1 [ ] ;
2024-01-31 14:29:39 +07:00
@OneToMany ( ( ) = > OrgChild2 , ( orgChild2 ) = > orgChild2 . orgChild1 )
orgChild2s : OrgChild2 [ ] ;
@OneToMany ( ( ) = > OrgChild3 , ( orgChild3 ) = > orgChild3 . orgChild1 )
orgChild3s : OrgChild3 [ ] ;
@OneToMany ( ( ) = > OrgChild4 , ( orgChild4 ) = > orgChild4 . orgChild1 )
orgChild4s : OrgChild4 [ ] ;
2024-09-06 09:41:47 +07:00
@OneToMany ( ( ) = > PermissionOrg , ( permissionOrg ) = > permissionOrg . orgRootTree )
permissionOrgRoots : PermissionOrg [ ] ;
2024-01-24 16:08:34 +07:00
}
2024-01-25 10:13:36 +07:00
export class CreateOrgRoot {
@Column ( )
orgRootName : string ;
@Column ( )
orgRootShortName : string ;
@Column ( )
orgRootCode : string ;
@Column ( )
orgRootRank : OrgRootRank ;
2024-06-20 11:58:51 +07:00
@Column ( )
orgRootRankSub? : string ;
2024-03-13 09:47:19 +07:00
2025-02-10 12:07:09 +07:00
@Column ( )
DEPARTMENT_CODE? : string ;
@Column ( )
DIVISION_CODE? : string ;
@Column ( )
SECTION_CODE? : string ;
@Column ( )
JOB_CODE? : string ;
2024-01-25 10:13:36 +07:00
@Column ( )
2024-01-26 15:54:07 +07:00
orgRootPhoneEx? : string ;
2024-01-25 10:13:36 +07:00
@Column ( )
2024-01-26 15:54:07 +07:00
orgRootPhoneIn? : string ;
2024-01-25 10:13:36 +07:00
@Column ( )
2024-01-26 15:54:07 +07:00
orgRootFax? : string ;
2024-01-25 10:13:36 +07:00
2024-05-14 11:55:00 +07:00
@Column ( )
2024-05-14 15:29:05 +07:00
responsibility? : string ;
2024-05-14 11:55:00 +07:00
2024-01-26 20:25:18 +07:00
@Column ( "uuid" )
orgRevisionId : string ;
2024-10-21 17:11:21 +07:00
@Column ( )
isDeputy : boolean ;
2025-01-17 16:11:30 +07:00
2025-01-20 15:14:00 +07:00
@Column ( )
isCommission : boolean ;
2025-01-17 16:11:30 +07:00
@Column ( )
misId? : string ;
2024-01-25 10:13:36 +07:00
}
2024-01-26 15:54:07 +07:00
export type UpdateOrgRoot = Partial < CreateOrgRoot > & { orgRootRank? : OrgRootRank } ;