2024-01-25 15:54:03 +07:00
import { Entity , Column , ManyToOne , JoinColumn , OneToMany , PrimaryGeneratedColumn } from "typeorm" ;
2024-01-24 16:08:34 +07:00
import { EntityBase } from "./base/Base" ;
import { OrgRoot } from "./OrgRoot" ;
import { OrgChild2 } from "./OrgChild2" ;
2024-01-31 14:29:39 +07:00
import { OrgRevision } from "./OrgRevision" ;
import { OrgChild3 } from "./OrgChild3" ;
import { OrgChild4 } from "./OrgChild4" ;
2024-01-31 15:31:20 +07:00
import { PosMaster } from "./PosMaster" ;
2024-01-24 16:08:34 +07:00
enum OrgChild1Rank {
2024-01-26 10:13:07 +07:00
DEPARTMENT = "DEPARTMENT" ,
OFFICE = "OFFICE" ,
DIVISION = "DIVISION" ,
SECTION = "SECTION" ,
2024-01-24 16:08:34 +07:00
}
2024-01-25 13:08:25 +07:00
2024-01-24 17:22:41 +07:00
@Entity ( "orgChild1" )
2024-01-24 16:08:34 +07:00
export class OrgChild1 extends EntityBase {
@Column ( {
nullable : true ,
comment : "ชื่อส่วนราชการ" ,
length : 255 ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-24 16:08:34 +07:00
} )
orgChild1Name : 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
} )
orgChild1ShortName : 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
} )
orgChild1Code : string ;
@Column ( {
nullable : true ,
comment : "ระดับส่วนราชการ" ,
type : "enum" ,
enum : OrgChild1Rank ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-24 16:08:34 +07:00
} )
orgChild1Rank : OrgChild1Rank ;
2024-03-13 09:47:19 +07:00
@Column ( {
nullable : true ,
comment : "ระดับส่วนราชการsub" ,
default : null ,
} )
orgChild1RankSub : string ;
2024-01-24 16:08:34 +07:00
@Column ( {
nullable : true ,
comment : "ลำดับที่ของส่วนราชการภายใน Child เดียวกัน" ,
2024-02-01 11:02:35 +07:00
default : null ,
2024-01-24 16:08:34 +07:00
} )
orgChild1Order : 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
} )
orgChild1PhoneEx : 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
} )
orgChild1PhoneIn : 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
} )
orgChild1Fax : string ;
@Column ( {
2024-01-26 20:25:18 +07:00
length : 40 ,
2024-02-01 14:17:56 +07:00
comment : "คีย์นอก(FK)ของตาราง orgRoot" ,
2024-01-24 16:08:34 +07:00
} )
2024-01-26 20:25:18 +07:00
orgRootId : string ;
2024-01-24 16:08:34 +07:00
@Column ( {
length : 40 ,
2024-02-01 14:17:56 +07:00
comment : "คีย์นอก(FK)ของตาราง orgRevision" ,
2024-01-24 16:08:34 +07:00
} )
2024-01-26 20:25:18 +07:00
orgRevisionId : string ;
2024-01-24 16:08:34 +07:00
2024-01-26 09:56:27 +07:00
@Column ( {
2024-02-01 11:02:35 +07:00
nullable : true ,
2024-01-26 09:56:27 +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-26 09:56:27 +07:00
} )
2024-02-01 13:29:15 +07:00
ancestorDNA : string ;
2024-01-26 09:56:27 +07:00
2024-05-14 14:37:23 +07:00
@Column ( {
nullable : true ,
length : 255 ,
comment : "หน้าที่ความรับผิดชอบ" ,
default : null ,
} )
2024-05-14 15:29:05 +07:00
responsibility : string ;
2024-05-14 14:37:23 +07:00
2024-01-31 14:29:39 +07:00
@ManyToOne ( ( ) = > OrgRevision , ( orgRevision ) = > orgRevision . orgChild1s )
@JoinColumn ( { name : "orgRevisionId" } )
orgRevision : OrgRevision ;
2024-01-26 17:09:28 +07:00
@ManyToOne ( ( ) = > OrgRoot , ( orgRoot ) = > orgRoot . orgChild1s )
2024-01-25 10:13:36 +07:00
@JoinColumn ( { name : "orgRootId" } )
2024-01-24 16:08:34 +07:00
orgRoot : OrgRoot ;
2024-01-26 17:09:28 +07:00
@OneToMany ( ( ) = > OrgChild2 , ( orgChild2 ) = > orgChild2 . orgChild1 )
2024-01-24 16:08:34 +07:00
orgChild2s : OrgChild2 [ ] ;
2024-01-31 14:29:39 +07:00
@OneToMany ( ( ) = > OrgChild3 , ( orgChild3 ) = > orgChild3 . orgChild1 )
orgChild3s : OrgChild3 [ ] ;
@OneToMany ( ( ) = > OrgChild4 , ( orgChild4 ) = > orgChild4 . orgChild1 )
orgChild4s : OrgChild4 [ ] ;
2024-01-31 15:31:20 +07:00
@OneToMany ( ( ) = > PosMaster , ( posMaster ) = > posMaster . orgChild1 )
posMasters : PosMaster [ ] ;
2024-01-25 11:09:54 +07:00
}
export class CreateOrgChild1 {
@Column ( )
orgChild1Name : string ;
@Column ( )
orgChild1ShortName : string ;
@Column ( )
2024-01-26 11:36:21 +07:00
orgChild1Code? : string ;
2024-01-26 17:09:28 +07:00
2024-01-25 11:09:54 +07:00
@Column ( )
orgChild1Rank : string ;
2024-03-13 09:47:19 +07:00
@Column ( )
2024-03-13 10:12:13 +07:00
orgChild1RankSub? : string ;
2024-03-13 09:47:19 +07:00
2024-01-25 11:09:54 +07:00
@Column ( )
2024-01-26 17:09:28 +07:00
orgChild1PhoneEx? : string ;
2024-01-25 11:09:54 +07:00
@Column ( )
2024-01-26 17:09:28 +07:00
orgChild1PhoneIn? : string ;
2024-01-25 11:09:54 +07:00
@Column ( )
2024-01-26 17:09:28 +07:00
orgChild1Fax? : string ;
2024-01-25 11:09:54 +07:00
2024-01-26 17:09:28 +07:00
@Column ( "uuid" )
2024-01-25 11:09:54 +07:00
orgRootId : string ;
2024-05-14 14:37:23 +07:00
2024-05-14 15:29:05 +07:00
@Column ( )
responsibility? : string ;
2024-01-24 16:08:34 +07:00
}
2024-01-25 11:09:54 +07:00
2024-01-25 13:08:25 +07:00
export type UpdateOrgChild1 = Partial < CreateOrgChild1 > & { orgChild1Rank? : OrgChild1Rank } ;