Compare commits

...

290 commits

Author SHA1 Message Date
0f4b9778ee update search 2025-08-18 16:36:23 +07:00
Bright
217354f653 api รายละเอียดรายการผลงาน ใช้.oรายงาน ก.พ.7/ก.ก.1 #1642 2025-08-06 10:53:06 +07:00
kittapath-Jool
d93edbf97a add noti 2025-08-01 15:54:00 +07:00
kittapath-Jool
0f5b9401ad delete dna post 2025-08-01 15:50:28 +07:00
8c51bcc920 delete log 2025-07-24 13:41:09 +07:00
9f21a4d498 #1412 2025-07-17 18:21:01 +07:00
06385990b5 #1635 2025-07-16 16:36:14 +07:00
e78811dfd6 #963 , #964 2025-07-16 15:10:37 +07:00
b95d59783b update 2025-07-16 14:26:48 +07:00
ce39e89cce update 2025-07-16 11:11:48 +07:00
468f0b304f #1626 2025-07-15 16:59:23 +07:00
Moss
d51357e715 migrate dna 2025-06-16 21:34:15 +07:00
e16390b787 fix sort developmentAddresss get tab3 2025-06-13 14:40:43 +07:00
374bec32e4 fix 2025-05-02 15:14:49 +07:00
Bright
65899d936a api รายละเอียดทุน & แก้ไขรายละเอียดทุน สำหรับเจ้าหน้าที่ 2025-04-23 09:27:31 +07:00
Bright
588178f042 migrate & เพิ่มฟิลด์ 2025-04-22 16:27:56 +07:00
Bright
8c7cbef72b [Edit SIT ระบบพัฒนา] รายการที่ต้องแก้ไข #1331 2025-04-22 10:14:31 +07:00
101eabbac0 add api portfolio/user 2025-04-18 14:34:11 +07:00
bb6364e7c0 fix 2025-04-17 14:33:12 +07:00
Bright
2eec9e5f60 no message 2025-04-11 15:46:28 +07:00
Bright
2e7bef0475 validate 2025-04-11 15:38:32 +07:00
Bright
dbfc678e92 migrate (ตัด relation ฟิลด์ posType, posLevel, empPosType, empPosLevel) 2025-04-11 10:58:34 +07:00
Bright
60781ea254 เพิ่ม/แก้ไข กลุ่มเป้าหมาย (ลูกจ้าง) 2025-04-10 16:20:30 +07:00
Bright
719da25875 รายการประวัติการฝึกอบรมลูกจ้าง & ระดับชั้นงานลูกจ้าง 2025-04-10 15:04:17 +07:00
Bright
cd6ef27116 filter หน่วยงาน รายการประวัติการฝึกอบรม 2025-04-10 13:59:19 +07:00
Bright
3163340215 แก้บัคระบบพัฒนา 2025-04-10 11:11:53 +07:00
moss
c6668cbc27 on noti 2025-04-01 01:34:54 +07:00
moss
9f41422b1b check type object log 2025-04-01 00:38:15 +07:00
moss
28df293eef sort 2025-03-28 21:44:55 +07:00
moss
c9845b0256 sort data 2025-03-28 15:10:26 +07:00
moss
00f76bbd2b add sort 2025-03-27 14:46:42 +07:00
moss
bd00213596 sort ยุทศาสตร์ 2025-03-25 10:32:06 +07:00
kittapath
e04d5fe1b1 Merge branch 'develop' of github.com:Frappet/bma-ehr-development into develop 2025-03-14 15:32:29 +07:00
kittapath
a4ebb83184 add pos exe 2025-03-14 15:32:17 +07:00
a003868b47 fixing error redis 2025-03-14 15:18:48 +07:00
kittapath
00d0f1f0fb edit report if no value 2025-02-13 21:52:49 +07:00
724a41a6a0 update 2025-02-13 20:02:25 +07:00
896928d3c7 update 2025-02-13 18:43:36 +07:00
04e6b6fa7d Merge branch 'develop' into adiDev
# Conflicts:
#	src/controllers/ReportController.ts
2025-02-13 18:11:59 +07:00
08bf5e53c6 fix 2025-02-13 18:08:39 +07:00
Bright
4dc2f476d2 update report + migrate 2025-02-13 18:07:32 +07:00
29fca33c2e fix 2025-02-13 18:01:34 +07:00
Bright
88af7fcbb0 migrate 2025-02-13 17:53:34 +07:00
Bright
dbce13d107 Merge branch 'develop' into develop-Bright 2025-02-13 17:38:43 +07:00
Bright
a13ef9cd9d Merge branch 'develop' of https://github.com/Frappet/bma-ehr-development into develop 2025-02-13 17:38:36 +07:00
Bright
92855fac40 update 3 4 2025-02-13 17:38:17 +07:00
3d7b32abbd Merge branch 'develop' into adiDev 2025-02-13 17:35:38 +07:00
a455c14ce6 update 2025-02-13 17:34:19 +07:00
Bright
5882e21a41 update report3 2025-02-13 11:15:13 +07:00
Bright
6e374d7992 report 3 (test) 2025-02-13 10:28:05 +07:00
f8c2433927 fix 2025-02-11 19:49:41 +07:00
3f1a46f709 Merge branch 'develop' into adiDev 2025-02-11 19:28:56 +07:00
4fdbc3fdcf add report endpoint fund 3 - 10 2025-02-11 19:23:29 +07:00
kittapath
4036194b55 add dna 2025-02-03 14:45:35 +07:00
kittapath
3e57b67432 search by ancestorDNA 2025-01-30 08:53:02 +07:00
dd8996336b report 2025-01-21 11:00:27 +07:00
f517b14eab fix 2025-01-21 09:22:42 +07:00
57c9326e54 Merge branch 'develop' into adiDev
# Conflicts:
#	src/controllers/ReportController.ts
2025-01-21 09:18:09 +07:00
d95b1a4129 checkpoint report 2025-01-20 18:20:09 +07:00
kittapath
4648331006 Merge branch 'develop' of github.com:Frappet/bma-ehr-development into develop
# Conflicts:
#	src/controllers/ReportController.ts
2025-01-20 14:54:56 +07:00
kittapath
f4140f45f8 report tamplate 2025-01-20 14:51:17 +07:00
9c1dc78eed reformat code 2025-01-20 13:23:31 +07:00
9c8fb66601 Merge branch 'develop' into adiDev 2025-01-17 20:04:38 +07:00
005e7582bf #826 checkpoint 2025-01-17 20:02:52 +07:00
kittapath
19598f1f81 update province 2025-01-17 17:52:13 +07:00
kittapath
668b05a511 no message 2024-12-26 23:31:05 +07:00
kittapath
4e59f47676 no message 2024-12-26 23:05:35 +07:00
kittapath
cc254227f8 Merge branch 'develop' 2024-12-26 22:19:10 +07:00
kittapath
127a994801 no message 2024-12-26 22:17:57 +07:00
kittapath
5658438ca5 Merge branch 'develop' 2024-12-24 00:46:06 +07:00
kittapath
3f988d8bb6 edit log 2024-12-20 10:03:51 +07:00
Bright
03e6a62c0a no message 2024-12-19 17:32:00 +07:00
Bright
e094c0ad07 แก้ทะเบียนประวัติ Individual Development Plan #875 2024-12-19 17:00:41 +07:00
fe9eca9b33 #857 (9) 2024-12-19 13:26:30 +07:00
d00e64d7df no message 2024-12-19 12:57:14 +07:00
964e938bb2 fix #857 2024-12-19 12:41:48 +07:00
kittapath
757783c96f Merge branch 'develop' 2024-12-19 11:46:01 +07:00
kittapath
a648fb3f24 migrate 2024-12-19 11:45:31 +07:00
kittapath
c0e38237a6 api clear db 2024-12-19 11:41:06 +07:00
48dcb3582a add relation 2024-12-19 11:14:57 +07:00
eb1264b885 #857 (4),(5) 2024-12-19 10:31:21 +07:00
kittapath
1ed7fa4a45 Merge branch 'develop' 2024-12-18 19:02:20 +07:00
kittapath
e251b16c11 แก้ throw error 2024-12-18 18:59:44 +07:00
kittapath
37e59199d2 Merge branch 'develop' 2024-12-18 10:00:33 +07:00
kittapath
86a5cd7fb5 edit permission 2024-12-14 01:04:10 +07:00
Suchin Sapphasitthatha
3a7a406936 add CI 2024-12-12 07:02:13 +00:00
536874adcc Merge branch 'adiDev' into develop 2024-12-11 13:52:33 +07:00
0c646b7c6e add status 2024-12-11 13:51:56 +07:00
kittapath
263cae0c55 test build discord 2024-12-07 09:31:49 +07:00
kittapath
837925b926 test build 2024-12-03 13:38:05 +07:00
Bright
1837cf09ac fix order 2024-11-28 17:49:15 +07:00
Bright
7469393551 เช็ค ระบบพัฒนา #811 2024-11-28 17:22:28 +07:00
Bright
531ebab3be fix เช็ค ระบบพัฒนา #811 2024-11-28 14:43:01 +07:00
Bright
06d6c07d3f sort เรียงจากวันที่สร้าง 2024-11-27 15:35:04 +07:00
Bright
483e64ffe3 sort เรียงจากวันที่สร้าง 2024-11-27 13:43:01 +07:00
786da60910 ระบบพัฒนาบุคลากร>>อัปโหลดไฟล์รายชื่อผู้ผ่านการฝึกอบรม (ลูกจ้างประจำ) #803 2024-11-22 11:16:57 +07:00
650cd842af add root id for log 2024-10-25 14:28:24 +07:00
kittapath
aa5e69776e check workflow 2024-10-22 08:21:07 +07:00
e0f37dda4a fix เพิ่ม 2024-10-03 15:20:33 +07:00
a16cc5e438 Merge branch 'develop' into adiDev 2024-10-03 15:14:47 +07:00
c0f387bda5 fix search 2024-10-03 15:14:12 +07:00
kittapath
2b1b5f2566 no message 2024-10-01 10:59:49 +07:00
kittapath
1deee019b2 แก้ฟิว 2024-10-01 10:31:25 +07:00
kittapath
2dce85a207 no message 2024-10-01 01:14:18 +07:00
kittapath
3069021568 no message 2024-10-01 01:03:13 +07:00
kittapath
e87e760075 comment 2024-10-01 00:41:09 +07:00
a5b57f287d fix 2024-09-30 17:01:31 +07:00
aa3bbac5a5 add search #619 2024-09-30 15:30:04 +07:00
kittapath
f8a91f60ba แก้ call api 2024-09-30 09:45:36 +07:00
0be33a3f3a แก้เส้น /api/v1/development/strategy/edit เพิ่ม /{page} 2024-09-13 11:07:04 +07:00
e27e74559f แก้ไขชื่อสิทธิ์ 2024-09-13 09:44:53 +07:00
08ba1032dc Merge branch 'develop' into adiDev 2024-09-12 14:17:36 +07:00
9fdb2ef2e7 เพิ่ม parth api ใช่ซ้ำกันในหลายเมนู (ข้อมูลแบบปนะเมิน>>>ตัวชี้วัด(รายละเอียดและแก้ไขข้อมูล)) 2024-09-12 14:16:43 +07:00
kittapath
ea776021e3 แก้ สิทธิ์ให้ค้นไวขึ้น 2024-09-06 15:25:15 +07:00
kittapath
a6493dcb62 แก้สิทธิ์ 2024-09-04 16:17:51 +07:00
kittapath
28f8c87fea ค้นหาลุกจ้างประจำ 2024-09-04 09:57:05 +07:00
kittapath
78ce7fa612 แก้ import data ไมพบข้อมูลในทะเบียนประวัติ 2024-09-03 19:08:13 +07:00
kittapath
8c39019f4a delete import dont use 2024-09-03 15:18:30 +07:00
kittapath
dd6e770ec7 เพิ่มวันเวลา แก้ไข/สร้าง 2024-09-03 14:59:53 +07:00
bc69873705 fix 2024-09-03 11:44:57 +07:00
d13da7269c add path admin(detail scholarship) 2024-08-30 14:17:29 +07:00
kittapath
3abd92e15f no message 2024-08-22 17:23:57 +07:00
kittapath
204984f63e ผูกสิท 2024-08-22 14:14:35 +07:00
kittapath
2a536dcc32 ผูกสิดข้อมูลหลัก 2024-08-21 22:09:56 +07:00
kittapath
666a7f8021 service call service 2024-08-15 13:28:20 +07:00
kittapath
5a92e60e0e no message 2024-08-13 11:08:49 +07:00
2ff993b840 role 2024-08-09 17:08:28 +07:00
3badc39ac2 fix 2024-08-08 15:28:29 +07:00
68299d2a07 Merge branch 'adiDev' into develop 2024-08-08 14:57:24 +07:00
567af430c1 fix 2024-08-08 14:56:11 +07:00
Bright
ae15f71a89 permission 2024-08-08 14:16:14 +07:00
04344cd4c5 fix 2024-08-08 14:04:14 +07:00
3320646521 tab 3 2024-08-08 13:27:23 +07:00
57240eded1 fix 2024-08-08 11:52:15 +07:00
b8575cd3a0 api tab5 2024-08-08 11:27:28 +07:00
Bright
15a730d4a9 migrate 2024-08-08 10:52:30 +07:00
3056dfeb2a migatation and get tab4 2024-08-08 10:39:44 +07:00
b9cc922edc Tab8 API 2024-08-07 18:15:55 +07:00
6fc0c04a9b migrate 2024-08-07 17:34:44 +07:00
8a36a6c977 get tab7 2024-08-07 15:08:40 +07:00
78fb5b5c0a update function tab 2024-08-07 14:03:40 +07:00
Kittapath
4c0c02cc8b ข้อมูลโครงการตามจริง 2024-08-06 10:41:17 +07:00
e1aa682105 fix 2024-08-01 17:48:28 +07:00
4ed904316d fix 2024-08-01 16:57:09 +07:00
5edd511f2a fix 2024-08-01 15:38:03 +07:00
61ec81687c fix log 2024-08-01 14:31:32 +07:00
9eb539b451 fix type 2024-07-31 10:15:24 +07:00
899b6acc56 fix 2024-07-31 09:55:56 +07:00
98811c0801 fix 2024-07-30 17:49:37 +07:00
293d41b0f2 fix 2024-07-30 17:23:45 +07:00
f027422d56 api uploadUser 2024-07-30 16:49:16 +07:00
02002a32a6 เพิ่มฟิว isProfile 2024-07-30 11:33:46 +07:00
29527c512e add prepare data log method:POST 2024-07-26 16:30:38 +07:00
cc26192b65 fix tab5 2024-07-25 17:39:58 +07:00
f6ee60eab9 fix 2024-07-25 17:31:01 +07:00
1c9cb7ea78 log 2024-07-25 17:06:42 +07:00
Bright
4b34fc20b8 no message 2024-07-17 13:58:37 +07:00
Bright
3fb7770344 no message 2024-07-17 13:19:20 +07:00
Kittapath
fa157f57c0 Merge branch 'develop' of github.com:Frappet/bma-ehr-development into develop
# Conflicts:
#	src/controllers/ReportController.ts
2024-07-17 12:49:07 +07:00
Kittapath
d45d18e592 edit report error 2024-07-17 12:47:36 +07:00
Bright
a746f8947b Fix Checkbox ไม่แสดง 2024-07-17 10:19:25 +07:00
Kittapath
3cb55d582c migrate 2024-07-15 21:29:38 +07:00
Kittapath
6856d15d63 Merge branch 'develop' of github.com:Frappet/bma-ehr-development into develop 2024-07-15 21:27:48 +07:00
Kittapath
3e686addec เพิ่ม รายละเอียดอื่นๆ 70 จริง 2024-07-15 21:27:38 +07:00
Methapon2001
08f8c598ac feat: change system name 2024-07-15 16:46:46 +07:00
Methapon2001
5ca06267d3 Reapply "feat: enable log"
This reverts commit 94226de168.
2024-07-15 16:45:48 +07:00
Methapon2001
272de6c455 feat: add log 2024-07-15 16:45:40 +07:00
Methapon2001
f8e1f9ab9d fix: error 2024-07-11 12:10:11 +07:00
Methapon2001
94226de168 Revert "feat: enable log"
This reverts commit 21d70dd3f5.
2024-07-11 12:04:32 +07:00
Methapon2001
a6c1df903c fix: log data type 2024-07-11 11:05:29 +07:00
Methapon2001
21d70dd3f5 feat: enable log 2024-07-11 10:58:18 +07:00
Methapon2001
04de0940ea Merge branch 'feat/log-middleware' into develop 2024-07-11 10:54:12 +07:00
Methapon2001
0d26d2d7a8 fix: change to string instead (or else cannot be search) 2024-07-11 10:54:03 +07:00
Methapon2001
ee1a1238eb feat: add user data to log 2024-07-11 10:29:40 +07:00
Kittapath
4dc342d018 no message 2024-07-10 10:45:01 +07:00
Methapon2001
f3161ab757 feat: add log middleware 2024-07-10 09:47:04 +07:00
Methapon2001
a842962db1 feat: add elasticsearch 2024-07-10 09:42:23 +07:00
Kittapath
a984acb683 แก้ env 2024-07-09 17:03:24 +07:00
Kittapath
9975f2c607 แก้env 2024-07-09 00:03:36 +07:00
Kittapath
eac232edcc แก้หมายเหตุพัฒนา 2024-07-05 17:36:19 +07:00
Bright
fdd9c510cc migrate 2024-07-05 14:42:48 +07:00
2e2a4336c1 ปรับฟิว detail เป็น longText 2024-07-01 11:42:34 +07:00
Kittapath
72a045fcfc add profilio 2024-06-30 20:50:39 +07:00
Kittapath
28bb5e2246 แก้ build 2024-06-11 11:59:13 +07:00
Kittapath
37f8b4c0bf no message 2024-05-21 18:24:27 +07:00
AnandaTon
fe6c92674b Update DevelopmentController.ts 2024-05-21 18:17:47 +07:00
AnandaTon
a428f59d9d แก้ไข path profile Employee traning 2024-05-21 16:50:51 +07:00
6ba5764fbb Merge branch 'adiDev' into develop 2024-05-21 15:40:46 +07:00
d310c3384e fix filter 2024-05-21 15:40:03 +07:00
AnandaTon
a56d469736 เพิ่มเงื่อนไข type 2024-05-21 15:19:20 +07:00
Kittapath
bd9b8b4183 migrate 2024-05-21 12:55:17 +07:00
AnandaTon
2584d26d6c แก้ไขให้เพิ่มข้อความยาวได้ 2024-05-21 11:11:33 +07:00
eb41d529c7 fix 2024-05-20 13:17:11 +07:00
Bright
422510dbe3 เพิ่มฟิลด์ totalPeriod 2024-05-17 10:05:15 +07:00
Kittapath
00df943de5 บันทึกการศึกษา 2024-05-03 17:38:39 +07:00
Kittapath
d101cbca4a no message 2024-04-30 14:14:51 +07:00
Kittapath
722adb571a Merge branch 'develop' of github.com:Frappet/bma-ehr-development into develop 2024-04-30 13:20:22 +07:00
Kittapath
5d98acafdb no message 2024-04-30 13:19:44 +07:00
Bright
d129fd7a47 เพิ่มค้นหาด้วยเลขบัตรประชน 2024-04-30 13:16:11 +07:00
Bright
71c547c5c6 เพิ่มฟิลด์เข้า report 2024-04-30 11:48:23 +07:00
47c275ef04 add field year 2024-04-29 14:51:12 +07:00
10b04aca44 Merge branch 'develop' into adiDev 2024-04-26 16:07:45 +07:00
8fe55d661d add orgRevisionId 2024-04-26 16:07:09 +07:00
Kittapath
e1640d2104 เพิ่ม node id 2024-04-26 10:18:20 +07:00
Kittapath
87c7452fa5 kpi แบบแผน 2024-04-19 09:28:57 +07:00
Kittapath
a840274150 เพิ่มฟิวหน่วยงานผู้ค้ำ 2024-04-18 16:17:37 +07:00
Kittapath
109bea3fc8 แก้apiยิงไปข้างนอก 2024-04-18 15:57:03 +07:00
afc42b743e Merge branch 'develop' into adiDev 2024-04-18 14:51:24 +07:00
1685ad224c fix bug 2024-04-18 14:50:49 +07:00
Kittapath
e8094726f0 filter ประวัติหน่วยงาน 2024-04-18 14:28:26 +07:00
Kittapath
9b0b51ea36 no message 2024-04-18 13:51:34 +07:00
4b5c82f744 fix function update 2024-04-18 11:47:24 +07:00
Kittapath
ddc0e85e3e โครงการเพิ่มค้นหาหน่วยงาน 2024-04-17 22:34:21 +07:00
Kittapath
281a8515ba Merge branch 'develop' of github.com:Frappet/bma-ehr-development into develop 2024-04-17 17:31:21 +07:00
Kittapath
d9c98f4f25 no message 2024-04-17 17:31:07 +07:00
83f92fc38c fix bug 2024-04-17 17:04:37 +07:00
Kittapath
5f5942089a Merge branch 'develop' of github.com:Frappet/bma-ehr-development into develop 2024-04-17 15:38:56 +07:00
2bdd4eba53 Merge branch 'adiDev' into develop 2024-04-17 15:38:13 +07:00
9f6443813c fix 2024-04-17 15:37:27 +07:00
Kittapath
9bb920f0d9 no message 2024-04-17 15:37:14 +07:00
Kittapath
e9a6f00431 no message 2024-04-17 15:27:37 +07:00
Kittapath
d21704baaf เพิ่มวันที่อัพไฟล์ 2024-04-17 15:01:33 +07:00
Kittapath
40c7a4675f no message 2024-04-17 14:45:55 +07:00
Kittapath
18fe85d7e2 Merge branch 'develop' of github.com:Frappet/bma-ehr-development into develop 2024-04-17 14:27:09 +07:00
Kittapath
c87c3f8fef เพิ่มจำนวนรุ่นตามแผน 2024-04-17 14:26:37 +07:00
893912b304 fix bug 2024-04-17 14:18:05 +07:00
d7b095b91f Merge branch 'develop' into adiDev 2024-04-17 13:57:07 +07:00
8a73302f6b fix format get 2024-04-17 13:56:10 +07:00
Kittapath
428ac7b2b4 no message 2024-04-17 13:42:26 +07:00
f3d2de51f7 fixparth 2024-04-17 10:40:11 +07:00
bee26f07a9 Merge branch 'develop' into adiDev 2024-04-17 10:21:32 +07:00
5e2fcfdf05 crud ผังยุทธศาสตร์ 2024-04-17 10:20:48 +07:00
Kittapath
422b0f3b87 โครงสร้างเพิ่มอัพโหลด user 2024-04-16 07:50:17 +07:00
Kittapath
be703f8e3b โครงการเพิ่มบันทึกยุทธศาสตร์ 2024-04-13 20:47:28 +07:00
Kittapath
650c6fe3e3 บันทึกหน่วยงาน 2024-04-12 14:22:44 +07:00
AnandaTon
371f09c26f api report รายการประวัติการฝึกอบรม/ดูงาน 2024-04-11 18:02:03 +07:00
Kittapath
a4eed4f690 api ทุน ของ user 2024-04-11 16:32:44 +07:00
Kittapath
37bf71aca5 Merge branch 'develop' of github.com:Frappet/bma-ehr-development into develop 2024-04-11 11:41:36 +07:00
Kittapath
4f8b2cec73 ปรับโครงาร 2024-04-11 11:39:56 +07:00
f14478274b enitity startegy 2024-04-11 11:35:19 +07:00
Kittapath
b8e1c93cb4 บันทึกลงทะเบียนประวัติ 2024-04-10 11:53:25 +07:00
Kittapath
166c919bbe เพิ่มตำแหน่งเลือกได้หลายอัน 2024-04-09 21:59:23 +07:00
Kittapath
68c31be431 useOfficialTime send false 2024-04-09 16:30:29 +07:00
Kittapath
58a30a7c74 set report development 2024-04-09 11:38:13 +07:00
3dc49ec507 fix 2024-04-05 15:45:06 +07:00
01cd72a9fa fix entity 2024-04-05 13:26:46 +07:00
7beac004b2 fix 2024-04-05 12:17:07 +07:00
7acf30d9a5 fix api 2024-04-05 12:01:30 +07:00
4ece5e8635 Merge branch 'develop' into adiDev 2024-04-05 10:27:53 +07:00
3de8591ce0 fix 2024-04-05 10:27:01 +07:00
Bright
f00c0d289e map DEV_015 2024-04-05 10:24:19 +07:00
14f5a082ca list 2024-04-05 10:19:28 +07:00
Kittapath
de746486d1 แก้ฟิวขอทุน 2024-04-04 19:59:28 +07:00
Bright
7e9aa4e0fa no message 2024-04-04 18:05:18 +07:00
Kittapath
daaa18b3c1 migrate 2024-04-04 17:52:47 +07:00
288266fbda fix api 2024-04-04 17:48:41 +07:00
5a3ab7cb17 Merge branch 'develop' into adiDev 2024-04-04 17:21:26 +07:00
c0f6c5ab9d fix entity and api 2024-04-04 17:20:44 +07:00
Bright
b91ffb1bba no message 2024-04-04 14:52:10 +07:00
Bright
6660ab230b no message 2024-04-04 14:40:38 +07:00
f793c2465b Merge branch 'develop' into adiDev 2024-04-04 14:17:49 +07:00
34902c15d5 devscholarship entity 2024-04-04 14:17:19 +07:00
Bright
d3ecbf3bd1 ดัก posType, posLevel มีค่า null 2024-04-04 11:31:42 +07:00
Bright
6ab68394a5 no message 2024-04-04 10:42:29 +07:00
786f0d51c8 Merge branch 'develop' into adiDev 2024-04-04 10:22:31 +07:00
b4108b8799 แก้ไขฟิว devemp 2024-04-04 10:21:53 +07:00
Bright
59d426f5d5 no message 2024-04-04 10:05:34 +07:00
Bright
e52e986d3b DEV_009 ลูกจ้าง 2024-04-03 20:15:58 +07:00
Kittapath
2e5d98d546 Merge branch 'develop' of github.com:Frappet/bma-ehr-development into develop
# Conflicts:
#	tsoa.json
2024-04-03 18:59:32 +07:00
Kittapath
8375ac1549 no message 2024-04-03 18:58:54 +07:00
Bright
c88a83f43e no message 2024-04-03 18:28:47 +07:00
Bright
3c2ce93724 DEV_009 เหลือ map 2024-04-03 18:10:46 +07:00
Kittapath
5a2f64ed72 Merge branch 'develop' of github.com:Frappet/bma-ehr-development into develop 2024-04-03 17:32:26 +07:00
Kittapath
61c44b8f51 no message 2024-04-03 17:32:11 +07:00
4f73cad70b แก้ชื่อฟิว 2024-04-03 17:08:39 +07:00
Kittapath
80f0a154f9 no message 2024-04-03 16:33:17 +07:00
Kittapath
682010fe66 no message 2024-04-03 16:14:00 +07:00
Kittapath
da6b3dcc4e Merge branch 'develop' of github.com:Frappet/bma-ehr-development into develop 2024-04-03 14:55:21 +07:00
Kittapath
daf4188144 ค้นหาโครงการ 2024-04-03 14:54:56 +07:00
e8a5fa5e42 DEV_10 (EMP) 2024-04-03 14:48:59 +07:00
2617791a31 Merge branch 'develop' into adiDev 2024-04-03 14:12:10 +07:00
d1b7330b91 DEV_010 2024-04-03 14:11:33 +07:00
Kittapath
8a5a7ac360 no message 2024-04-03 13:38:58 +07:00
Kittapath
4d4306863d เพิ่มฟิวตำแหน่งทางการบริหาร 2024-04-03 13:36:59 +07:00
Kittapath
4aabc4d136 no message 2024-04-03 12:10:30 +07:00
Kittapath
44022b311f เพิ่มประวัติลูกจ้าง 2024-04-03 12:07:57 +07:00
Kittapath
e9732a1e52 ประวัติราชการ 2024-04-03 11:48:06 +07:00
Kittapath
a5ee4afd06 ประวัติโครงการลูกจ้่าง 2024-04-03 11:28:08 +07:00
Kittapath
c2af2a3b08 api ชื่อโครงการ/กิจกรรม/หลักสูตร 2024-04-03 00:55:40 +07:00
Bright
9da7f47cf6 crud development 2024-04-02 17:53:45 +07:00
96 changed files with 13382 additions and 103 deletions

View file

@ -1,5 +1,5 @@
name: release-test
run-name: release-test ${{ github.actor }}
name: release
run-name: release ${{ github.actor }}
on:
push:
tags:
@ -7,12 +7,13 @@ on:
workflow_dispatch:
env:
REGISTRY: docker.frappet.com
IMAGE_NAME: ehr/bma-ehr-org-service
DEPLOY_HOST: 192.168.1.80
COMPOSE_PATH: /home/frappet/docker/bma-ehr
IMAGE_NAME: ehr/bma-ehr-development-service
DEPLOY_HOST: frappet.com
COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-development
jobs:
# act workflow_dispatch -W .github/workflows/release.yaml --input IMAGE_VER=test-v1 -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd
release-test:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
@ -51,6 +52,7 @@ jobs:
with:
context: .
platforms: linux/amd64
file: docker/Dockerfile
push: true
tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
- name: Remote Deployment
@ -59,27 +61,46 @@ jobs:
host: ${{env.DEPLOY_HOST}}
username: frappet
password: ${{ secrets.SSH_PASSWORD }}
port: 22
port: 10102
script: |
cd "${{env.COMPOSE_PATH}}"
docker-compose pull
docker-compose up -d
docker compose pull
docker compose up -d
echo "${{ steps.gen_ver.outputs.image_ver }}"> success
- uses: snow-actions/line-notify@v1.1.0
- name: Notify Discord Success
if: success()
with:
access_token: ${{ secrets.TOKEN_LINE }}
message: |
-Success✅✅✅
Image: ${{env.IMAGE_NAME}}
Version: ${{ steps.gen_ver.outputs.IMAGE_VER }}
By: ${{secrets.DOCKER_USER}}
- uses: snow-actions/line-notify@v1.1.0
run: |
curl -H "Content-Type: application/json" \
-X POST \
-d '{
"embeds": [{
"title": "✅ Deployment Success!",
"description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`",
"color": 3066993,
"footer": {
"text": "Release Notification",
"icon_url": "https://example.com/success-icon.png"
},
"timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
}]
}' \
${{ secrets.DISCORD_WEBHOOK }}
- name: Notify Discord Failure
if: failure()
with:
access_token: ${{ secrets.TOKEN_LINE }}
message: |
-Failure❌❌❌
Image: ${{env.IMAGE_NAME}}
Version: ${{ steps.gen_ver.outputs.IMAGE_VER }}
By: ${{secrets.DOCKER_USER}}
run: |
curl -H "Content-Type: application/json" \
-X POST \
-d '{
"embeds": [{
"title": "❌ Deployment Failed!",
"description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`",
"color": 15158332,
"footer": {
"text": "Release Notification",
"icon_url": "https://example.com/failure-icon.png"
},
"timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
}]
}' \
${{ secrets.DISCORD_WEBHOOK }}

102
.onedev-buildspec.yml Normal file
View file

@ -0,0 +1,102 @@
version: 37
jobs:
- name: CI for UAT
steps:
- !CheckoutStep
name: checkout code
cloneCredential: !DefaultCredential {}
withLfs: false
withSubmodules: false
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !GenerateChecksumStep
name: generate package checksum
files: package-lock.json yarn.lock
targetFile: checksum
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !SetupCacheStep
name: set up npm cache
key: node_modules_@file:checksum@
loadKeys:
- node_modules
paths:
- node_modules
uploadStrategy: UPLOAD_IF_NOT_HIT
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !SetBuildVersionStep
name: set build version
buildVersion: '@tag@'
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !CommandStep
name: build & test
runInContainer: true
image: node
interpreter: !DefaultInterpreter
commands: |
npm install
npm run build
useTTY: true
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !BuildImageStep
name: build docker image
dockerfile: ./docker/Dockerfile
output: !RegistryOutput
tags: hrms-git.chin.in.th/bma-hrms/hrms-api-dev:@build_version@ hrms-git.chin.in.th/bma-hrms/hrms-api-dev:latest
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
triggers:
- !TagCreateTrigger
tags: uat-*
branches: main
retryCondition: never
maxRetries: 3
retryDelay: 30
timeout: 14400
- name: CI for PROD
steps:
- !CheckoutStep
name: checkout code
cloneCredential: !DefaultCredential {}
withLfs: false
withSubmodules: false
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !GenerateChecksumStep
name: generate package checksum
files: package-lock.json yarn.lock
targetFile: checksum
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !SetupCacheStep
name: set up npm cache
key: node_modules_@file:checksum@
loadKeys:
- node_modules
paths:
- node_modules
uploadStrategy: UPLOAD_IF_NOT_HIT
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !SetBuildVersionStep
name: set build version
buildVersion: '@tag@'
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !CommandStep
name: build & test
runInContainer: true
image: node
interpreter: !DefaultInterpreter
commands: |
npm install
npm run build
useTTY: true
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
- !BuildImageStep
name: build docker image
dockerfile: ./docker/Dockerfile
output: !RegistryOutput
tags: hrms-git.bangkok.go.th/bma-hrms/hrms-api-dev:@build_version@ hrms-git.bangkok.go.th/bma-hrms/hrms-api-dev:latest
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
triggers:
- !TagCreateTrigger
tags: prod-*
branches: main
retryCondition: never
maxRetries: 3
retryDelay: 30
timeout: 14400

View file

@ -1,35 +0,0 @@
FROM node:18-alpine as builder
# Create app directory
WORKDIR /app
# Install app dependencies
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:18-alpine
ENV NODE_ENV production
USER node
# Create app directory
WORKDIR /app
# Install app dependencies
COPY package*.json ./
# COPY .env ./
RUN npm ci --production
COPY --from=builder /app/dist ./dist
# COPY entrypoint.sh /usr/local/bin/entrypoint.sh
# RUN chmod u+x /usr/local/bin/entrypoint.sh
# ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD [ "node", "dist/app.js" ]

34
docker/Dockerfile Normal file
View file

@ -0,0 +1,34 @@
# Build Stage
FROM node:lts-alpine AS build-stage
# Create app directory
WORKDIR /app
# Install app dependencies
COPY package*.json ./
RUN npm ci
# Copy source files and build the app
COPY . .
RUN npm run build
# Production Stage
FROM node:lts-alpine
ENV NODE_ENV production
USER node
# Create app directory
WORKDIR /app
# Copy built app from build stage
COPY --from=build-stage /app/dist ./dist
# Install only production dependencies
COPY package*.json ./
RUN npm ci --production
# Define the entrypoint and default command
# If you have a custom entrypoint script
CMD [ "node", "dist/app.js" ]

683
package-lock.json generated
View file

@ -9,19 +9,25 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"@elastic/elasticsearch": "^8.14.0",
"@nestjs/platform-express": "^10.3.7",
"@tsoa/runtime": "^6.0.0",
"axios": "^1.6.8",
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"fast-jwt": "^3.3.2",
"multer": "^1.4.5-lts.1",
"mysql2": "^3.9.1",
"node-cron": "^3.0.3",
"promise.any": "^2.0.6",
"redis": "~3.1.2",
"reflect-metadata": "^0.2.1",
"swagger-ui-express": "^5.0.0",
"tsoa": "^6.0.1",
"typeorm": "^0.3.19",
"typeorm-cli": "^1.0.7"
"typeorm-cli": "^1.0.7",
"xlsx": "^0.18.5"
},
"devDependencies": {
"@types/cors": "^2.8.17",
@ -47,6 +53,66 @@
"node": ">=12"
}
},
"node_modules/@elastic/elasticsearch": {
"version": "8.14.0",
"resolved": "https://registry.npmjs.org/@elastic/elasticsearch/-/elasticsearch-8.14.0.tgz",
"integrity": "sha512-MGrgCI4y+Ozssf5Q2IkVJlqt5bUMnKIICG2qxeOfrJNrVugMCBCAQypyesmSSocAtNm8IX3LxfJ3jQlFHmKe2w==",
"license": "Apache-2.0",
"dependencies": {
"@elastic/transport": "^8.6.0",
"tslib": "^2.4.0"
},
"engines": {
"node": ">=18"
}
},
"node_modules/@elastic/transport": {
"version": "8.7.0",
"resolved": "https://registry.npmjs.org/@elastic/transport/-/transport-8.7.0.tgz",
"integrity": "sha512-IqXT7a8DZPJtqP2qmX1I2QKmxYyN27kvSW4g6pInESE1SuGwZDp2FxHJ6W2kwmYOJwQdAt+2aWwzXO5jHo9l4A==",
"license": "Apache-2.0",
"dependencies": {
"@opentelemetry/api": "1.x",
"debug": "^4.3.4",
"hpagent": "^1.0.0",
"ms": "^2.1.3",
"secure-json-parse": "^2.4.0",
"tslib": "^2.4.0",
"undici": "^6.12.0"
},
"engines": {
"node": ">=18"
}
},
"node_modules/@elastic/transport/node_modules/debug": {
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz",
"integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==",
"license": "MIT",
"dependencies": {
"ms": "2.1.2"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/@elastic/transport/node_modules/debug/node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"license": "MIT"
},
"node_modules/@elastic/transport/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
},
"node_modules/@isaacs/cliui": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz",
@ -88,6 +154,15 @@
"@jridgewell/sourcemap-codec": "^1.4.10"
}
},
"node_modules/@lukeed/csprng": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@lukeed/csprng/-/csprng-1.1.0.tgz",
"integrity": "sha512-Z7C/xXCiGWsg0KuKsHTKJxbWhpI3Vs5GwLfOean7MGyVFGqdRgBbAjOCh6u4bbjPc/8MJ2pZmK/0DLdCbivLDA==",
"peer": true,
"engines": {
"node": ">=8"
}
},
"node_modules/@lukeed/ms": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/@lukeed/ms/-/ms-2.0.2.tgz",
@ -96,11 +171,159 @@
"node": ">=8"
}
},
"node_modules/@nestjs/common": {
"version": "10.3.7",
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-10.3.7.tgz",
"integrity": "sha512-gKFtFzcJznrwsRYjtNZoPAvSOPYdNgxbTYoAyLTpoy393cIKgLmJTHu6ReH8/qIB9AaZLdGaFLkx98W/tFWFUw==",
"peer": true,
"dependencies": {
"iterare": "1.2.1",
"tslib": "2.6.2",
"uid": "2.0.2"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/nest"
},
"peerDependencies": {
"class-transformer": "*",
"class-validator": "*",
"reflect-metadata": "^0.1.12 || ^0.2.0",
"rxjs": "^7.1.0"
},
"peerDependenciesMeta": {
"class-transformer": {
"optional": true
},
"class-validator": {
"optional": true
}
}
},
"node_modules/@nestjs/core": {
"version": "10.3.7",
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-10.3.7.tgz",
"integrity": "sha512-hsdlnfiQ3kgqHL5k7js3CU0PV7hBJVi+LfFMgCkoagRxNMf67z0GFGeOV2jk5d65ssB19qdYsDa1MGVuEaoUpg==",
"hasInstallScript": true,
"peer": true,
"dependencies": {
"@nuxtjs/opencollective": "0.3.2",
"fast-safe-stringify": "2.1.1",
"iterare": "1.2.1",
"path-to-regexp": "3.2.0",
"tslib": "2.6.2",
"uid": "2.0.2"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/nest"
},
"peerDependencies": {
"@nestjs/common": "^10.0.0",
"@nestjs/microservices": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/websockets": "^10.0.0",
"reflect-metadata": "^0.1.12 || ^0.2.0",
"rxjs": "^7.1.0"
},
"peerDependenciesMeta": {
"@nestjs/microservices": {
"optional": true
},
"@nestjs/platform-express": {
"optional": true
},
"@nestjs/websockets": {
"optional": true
}
}
},
"node_modules/@nestjs/core/node_modules/path-to-regexp": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-3.2.0.tgz",
"integrity": "sha512-jczvQbCUS7XmS7o+y1aEO9OBVFeZBQ1MDSEqmO7xSoPgOPoowY/SxLpZ6Vh97/8qHZOteiCKb7gkG9gA2ZUxJA==",
"peer": true
},
"node_modules/@nestjs/platform-express": {
"version": "10.3.7",
"resolved": "https://registry.npmjs.org/@nestjs/platform-express/-/platform-express-10.3.7.tgz",
"integrity": "sha512-noNJ+PyIxQJLCKfuXz0tcQtlVAynfLIuKy62g70lEZ86UrIqSrZFqvWs/rFUgkbT6J8H7Rmv11hASOnX+7M2rA==",
"dependencies": {
"body-parser": "1.20.2",
"cors": "2.8.5",
"express": "4.19.2",
"multer": "1.4.4-lts.1",
"tslib": "2.6.2"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/nest"
},
"peerDependencies": {
"@nestjs/common": "^10.0.0",
"@nestjs/core": "^10.0.0"
}
},
"node_modules/@nestjs/platform-express/node_modules/mkdirp": {
"version": "0.5.6",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
"dependencies": {
"minimist": "^1.2.6"
},
"bin": {
"mkdirp": "bin/cmd.js"
}
},
"node_modules/@nestjs/platform-express/node_modules/multer": {
"version": "1.4.4-lts.1",
"resolved": "https://registry.npmjs.org/multer/-/multer-1.4.4-lts.1.tgz",
"integrity": "sha512-WeSGziVj6+Z2/MwQo3GvqzgR+9Uc+qt8SwHKh3gvNPiISKfsMfG4SvCOFYlxxgkXt7yIV2i1yczehm0EOKIxIg==",
"dependencies": {
"append-field": "^1.0.0",
"busboy": "^1.0.0",
"concat-stream": "^1.5.2",
"mkdirp": "^0.5.4",
"object-assign": "^4.1.1",
"type-is": "^1.6.4",
"xtend": "^4.0.0"
},
"engines": {
"node": ">= 6.0.0"
}
},
"node_modules/@nuxtjs/opencollective": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/@nuxtjs/opencollective/-/opencollective-0.3.2.tgz",
"integrity": "sha512-um0xL3fO7Mf4fDxcqx9KryrB7zgRM5JSlvGN5AGkP6JLM5XEKyjeAiPbNxdXVXQ16isuAhYpvP88NgL2BGd6aA==",
"peer": true,
"dependencies": {
"chalk": "^4.1.0",
"consola": "^2.15.0",
"node-fetch": "^2.6.1"
},
"bin": {
"opencollective": "bin/opencollective.js"
},
"engines": {
"node": ">=8.0.0",
"npm": ">=5.0.0"
}
},
"node_modules/@one-ini/wasm": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/@one-ini/wasm/-/wasm-0.1.1.tgz",
"integrity": "sha512-XuySG1E38YScSJoMlqovLru4KTUNSjgVTIjyh7qMX6aNN5HY5Ct5LhRJdxO79JtTzKfzV/bnWpz+zquYrISsvw=="
},
"node_modules/@opentelemetry/api": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.0.tgz",
"integrity": "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==",
"license": "Apache-2.0",
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/@pkgjs/parseargs": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz",
@ -364,6 +587,14 @@
"node": ">=0.4.0"
}
},
"node_modules/adler-32": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.3.1.tgz",
"integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==",
"engines": {
"node": ">=0.8"
}
},
"node_modules/align-text": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz",
@ -436,6 +667,11 @@
"node": ">= 6.0.0"
}
},
"node_modules/append-field": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz",
"integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw=="
},
"node_modules/arg": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
@ -520,6 +756,11 @@
"resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz",
"integrity": "sha512-eAkdoKxU6/LkKDBzLpT+t6Ff5EtfSF4wx1WfJiPEEV7WNLnDaRXk0oVysiEPm262roaachGexwUv94WhSgN5TQ=="
},
"node_modules/asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
},
"node_modules/available-typed-arrays": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz",
@ -531,6 +772,16 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/axios": {
"version": "1.6.8",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz",
"integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==",
"dependencies": {
"follow-redirects": "^1.15.6",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
@ -578,12 +829,12 @@
"integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA=="
},
"node_modules/body-parser": {
"version": "1.20.1",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz",
"integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==",
"version": "1.20.2",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz",
"integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==",
"dependencies": {
"bytes": "3.1.2",
"content-type": "~1.0.4",
"content-type": "~1.0.5",
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
@ -591,7 +842,7 @@
"iconv-lite": "0.4.24",
"on-finished": "2.4.1",
"qs": "6.11.0",
"raw-body": "2.5.1",
"raw-body": "2.5.2",
"type-is": "~1.6.18",
"unpipe": "1.0.0"
},
@ -649,6 +900,17 @@
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="
},
"node_modules/busboy": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
"integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==",
"dependencies": {
"streamsearch": "^1.1.0"
},
"engines": {
"node": ">=10.16.0"
}
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
@ -690,6 +952,18 @@
"node": ">=0.10.0"
}
},
"node_modules/cfb": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/cfb/-/cfb-1.2.2.tgz",
"integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==",
"dependencies": {
"adler-32": "~1.3.0",
"crc-32": "~1.2.0"
},
"engines": {
"node": ">=0.8"
}
},
"node_modules/chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
@ -946,6 +1220,14 @@
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
}
},
"node_modules/codepage": {
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/codepage/-/codepage-1.15.0.tgz",
"integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA==",
"engines": {
"node": ">=0.8"
}
},
"node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
@ -967,6 +1249,17 @@
"resolved": "https://registry.npmjs.org/colors-console/-/colors-console-1.0.3.tgz",
"integrity": "sha512-Q31K32UwadWqAxs+Iu46gNm4HJqUwrTJT2zen5NnhkKE5w7uqeZQZiuODUOxM/zOtHfiUTkia0io6zbN/VcCUQ=="
},
"node_modules/combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"dependencies": {
"delayed-stream": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/commander": {
"version": "2.20.3",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
@ -977,6 +1270,20 @@
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="
},
"node_modules/concat-stream": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
"integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
"engines": [
"node >= 0.8"
],
"dependencies": {
"buffer-from": "^1.0.0",
"inherits": "^2.0.3",
"readable-stream": "^2.2.2",
"typedarray": "^0.0.6"
}
},
"node_modules/config-chain": {
"version": "1.1.13",
"resolved": "https://registry.npmjs.org/config-chain/-/config-chain-1.1.13.tgz",
@ -986,6 +1293,12 @@
"proto-list": "~1.2.1"
}
},
"node_modules/consola": {
"version": "2.15.3",
"resolved": "https://registry.npmjs.org/consola/-/consola-2.15.3.tgz",
"integrity": "sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw==",
"peer": true
},
"node_modules/content-disposition": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
@ -1006,9 +1319,9 @@
}
},
"node_modules/cookie": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz",
"integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==",
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz",
"integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==",
"engines": {
"node": ">= 0.6"
}
@ -1035,6 +1348,17 @@
"node": ">= 0.10"
}
},
"node_modules/crc-32": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz",
"integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==",
"bin": {
"crc32": "bin/crc32.njs"
},
"engines": {
"node": ">=0.8"
}
},
"node_modules/create-require": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
@ -1112,6 +1436,14 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/denque": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz",
@ -1390,16 +1722,16 @@
}
},
"node_modules/express": {
"version": "4.18.2",
"resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz",
"integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==",
"version": "4.19.2",
"resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz",
"integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==",
"dependencies": {
"accepts": "~1.3.8",
"array-flatten": "1.1.1",
"body-parser": "1.20.1",
"body-parser": "1.20.2",
"content-disposition": "0.5.4",
"content-type": "~1.0.4",
"cookie": "0.5.0",
"cookie": "0.6.0",
"cookie-signature": "1.0.6",
"debug": "2.6.9",
"depd": "2.0.0",
@ -1457,6 +1789,12 @@
"node": ">=16 <22"
}
},
"node_modules/fast-safe-stringify": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz",
"integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==",
"peer": true
},
"node_modules/figures": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz",
@ -1497,6 +1835,25 @@
"node": ">= 0.8"
}
},
"node_modules/follow-redirects": {
"version": "1.15.6",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
"integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
},
"node_modules/for-each": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz",
@ -1520,6 +1877,19 @@
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
@ -1528,6 +1898,14 @@
"node": ">= 0.6"
}
},
"node_modules/frac": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/frac/-/frac-1.1.2.tgz",
"integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==",
"engines": {
"node": ">=0.8"
}
},
"node_modules/fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
@ -1833,6 +2211,15 @@
"node": "*"
}
},
"node_modules/hpagent": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/hpagent/-/hpagent-1.2.0.tgz",
"integrity": "sha512-A91dYTeIB6NoXG+PxTQpCCDDnfHsW9kc06Lvpu1TEe9gnd6ZFeiBoRO9JvzEv6xK7EX97/dUE8g/vBMTqTS3CA==",
"license": "MIT",
"engines": {
"node": ">=14"
}
},
"node_modules/http-errors": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
@ -1979,6 +2366,17 @@
"node": ">=4"
}
},
"node_modules/inquirer/node_modules/rxjs": {
"version": "6.6.7",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz",
"integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==",
"dependencies": {
"tslib": "^1.9.0"
},
"engines": {
"npm": ">=2.0.0"
}
},
"node_modules/inquirer/node_modules/string-width": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
@ -2021,6 +2419,11 @@
"node": ">=6"
}
},
"node_modules/inquirer/node_modules/tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
},
"node_modules/internal-slot": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.6.tgz",
@ -2322,6 +2725,15 @@
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="
},
"node_modules/iterare": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/iterare/-/iterare-1.2.1.tgz",
"integrity": "sha512-RKYVTCjAnRthyJes037NX/IiqeidgN1xc3j1RjFfECFp28A1GVwK9nA+i0rJPaHqSZwygLzRnFlzUuHFoWWy+Q==",
"peer": true,
"engines": {
"node": ">=6"
}
},
"node_modules/iterate-iterator": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/iterate-iterator/-/iterate-iterator-1.0.2.tgz",
@ -2625,6 +3037,34 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
},
"node_modules/multer": {
"version": "1.4.5-lts.1",
"resolved": "https://registry.npmjs.org/multer/-/multer-1.4.5-lts.1.tgz",
"integrity": "sha512-ywPWvcDMeH+z9gQq5qYHCCy+ethsk4goepZ45GLD63fOu0YcNecQxi64nDs3qluZB+murG3/D4dJ7+dGctcCQQ==",
"dependencies": {
"append-field": "^1.0.0",
"busboy": "^1.0.0",
"concat-stream": "^1.5.2",
"mkdirp": "^0.5.4",
"object-assign": "^4.1.1",
"type-is": "^1.6.4",
"xtend": "^4.0.0"
},
"engines": {
"node": ">= 6.0.0"
}
},
"node_modules/multer/node_modules/mkdirp": {
"version": "0.5.6",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
"dependencies": {
"minimist": "^1.2.6"
},
"bin": {
"mkdirp": "bin/cmd.js"
}
},
"node_modules/mute-stream": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz",
@ -2747,6 +3187,26 @@
"uuid": "dist/bin/uuid"
}
},
"node_modules/node-fetch": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
"peer": true,
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/nodemon": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.0.3.tgz",
@ -3067,6 +3527,11 @@
"node": ">= 0.10"
}
},
"node_modules/proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"node_modules/pstree.remy": {
"version": "1.1.8",
"resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz",
@ -3096,9 +3561,9 @@
}
},
"node_modules/raw-body": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz",
"integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==",
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
"integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
"dependencies": {
"bytes": "3.1.2",
"http-errors": "2.0.0",
@ -3145,6 +3610,56 @@
"node": ">=8.10.0"
}
},
"node_modules/redis": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/redis/-/redis-3.1.2.tgz",
"integrity": "sha512-grn5KoZLr/qrRQVwoSkmzdbw6pwF+/rwODtrOr6vuBRiR/f3rjSTGupbF90Zpqm2oenix8Do6RV7pYEkGwlKkw==",
"dependencies": {
"denque": "^1.5.0",
"redis-commands": "^1.7.0",
"redis-errors": "^1.2.0",
"redis-parser": "^3.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/node-redis"
}
},
"node_modules/redis-commands": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.7.0.tgz",
"integrity": "sha512-nJWqw3bTFy21hX/CPKHth6sfhZbdiHP6bTawSgQBlKOVRG7EZkfHbbHwQJnrE4vsQf0CMNE+3gJ4Fmm16vdVlQ=="
},
"node_modules/redis-errors": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz",
"integrity": "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==",
"engines": {
"node": ">=4"
}
},
"node_modules/redis-parser": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz",
"integrity": "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==",
"dependencies": {
"redis-errors": "^1.0.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/redis/node_modules/denque": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/denque/-/denque-1.5.1.tgz",
"integrity": "sha512-XwE+iZ4D6ZUB7mfYRMb5wByE8L74HCn30FBN7sWnXksWc1LO1bPDl67pBR9o/kC4z/xSNAwkMYcGgqDV3BE3Hw==",
"engines": {
"node": ">=0.10"
}
},
"node_modules/reflect-metadata": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.2.1.tgz",
@ -3219,21 +3734,14 @@
}
},
"node_modules/rxjs": {
"version": "6.6.7",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz",
"integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==",
"version": "7.8.1",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz",
"integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==",
"peer": true,
"dependencies": {
"tslib": "^1.9.0"
},
"engines": {
"npm": ">=2.0.0"
"tslib": "^2.1.0"
}
},
"node_modules/rxjs/node_modules/tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
},
"node_modules/safe-array-concat": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.1.0.tgz",
@ -3296,6 +3804,12 @@
"resolved": "https://registry.npmjs.org/sax/-/sax-1.3.0.tgz",
"integrity": "sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA=="
},
"node_modules/secure-json-parse": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-2.7.0.tgz",
"integrity": "sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==",
"license": "BSD-3-Clause"
},
"node_modules/semver": {
"version": "7.5.4",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
@ -3498,6 +4012,17 @@
"node": ">= 0.6"
}
},
"node_modules/ssf": {
"version": "0.11.2",
"resolved": "https://registry.npmjs.org/ssf/-/ssf-0.11.2.tgz",
"integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==",
"dependencies": {
"frac": "~1.1.2"
},
"engines": {
"node": ">=0.8"
}
},
"node_modules/statuses": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
@ -3517,6 +4042,14 @@
"node": ">= 0.4"
}
},
"node_modules/streamsearch": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",
"integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==",
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
@ -3827,6 +4360,12 @@
"nodetouch": "bin/nodetouch.js"
}
},
"node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
"peer": true
},
"node_modules/ts-node": {
"version": "10.9.2",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz",
@ -3964,6 +4503,11 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/typedarray": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
"integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA=="
},
"node_modules/typeorm": {
"version": "0.3.19",
"resolved": "https://registry.npmjs.org/typeorm/-/typeorm-0.3.19.tgz",
@ -4418,6 +4962,18 @@
"resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz",
"integrity": "sha512-vb2s1lYx2xBtUgy+ta+b2J/GLVUR+wmpINwHePmPRhOsIVCG2wDzKJ0n14GslH1BifsqVzSOwQhRaCAsZ/nI4Q=="
},
"node_modules/uid": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/uid/-/uid-2.0.2.tgz",
"integrity": "sha512-u3xV3X7uzvi5b1MncmZo3i2Aw222Zk1keqLA1YkHldREkAhAqi65wuPfe7lHx8H/Wzy+8CE7S7uS3jekIM5s8g==",
"peer": true,
"dependencies": {
"@lukeed/csprng": "^1.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/unbox-primitive": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",
@ -4438,6 +4994,15 @@
"integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==",
"dev": true
},
"node_modules/undici": {
"version": "6.19.2",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.19.2.tgz",
"integrity": "sha512-JfjKqIauur3Q6biAtHJ564e3bWa8VvT+7cSiOJHFbX4Erv6CLGDpg8z+Fmg/1OI/47RA+GI2QZaF48SSaLvyBA==",
"license": "MIT",
"engines": {
"node": ">=18.17"
}
},
"node_modules/undici-types": {
"version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
@ -4514,6 +5079,22 @@
"loose-envify": "^1.0.0"
}
},
"node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
"peer": true
},
"node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"peer": true,
"dependencies": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
@ -4569,6 +5150,22 @@
"node": ">= 0.8.0"
}
},
"node_modules/wmf": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wmf/-/wmf-1.0.2.tgz",
"integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==",
"engines": {
"node": ">=0.8"
}
},
"node_modules/word": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/word/-/word-0.3.0.tgz",
"integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==",
"engines": {
"node": ">=0.8"
}
},
"node_modules/wordwrap": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
@ -4660,6 +5257,26 @@
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="
},
"node_modules/xlsx": {
"version": "0.18.5",
"resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.18.5.tgz",
"integrity": "sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ==",
"dependencies": {
"adler-32": "~1.3.0",
"cfb": "~1.2.1",
"codepage": "~1.15.0",
"crc-32": "~1.2.1",
"ssf": "~0.11.2",
"wmf": "~1.0.1",
"word": "~0.3.0"
},
"bin": {
"xlsx": "bin/xlsx.njs"
},
"engines": {
"node": ">=0.8"
}
},
"node_modules/xml2js": {
"version": "0.4.23",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz",
@ -4680,6 +5297,14 @@
"node": ">=4.0"
}
},
"node_modules/xtend": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
"integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==",
"engines": {
"node": ">=0.4"
}
},
"node_modules/y18n": {
"version": "5.0.8",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",

View file

@ -27,11 +27,15 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@elastic/elasticsearch": "^8.14.0",
"@nestjs/platform-express": "^10.3.7",
"@tsoa/runtime": "^6.0.0",
"axios": "^1.6.8",
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"fast-jwt": "^3.3.2",
"multer": "^1.4.5-lts.1",
"mysql2": "^3.9.1",
"node-cron": "^3.0.3",
"promise.any": "^2.0.6",
@ -39,6 +43,8 @@
"swagger-ui-express": "^5.0.0",
"tsoa": "^6.0.1",
"typeorm": "^0.3.19",
"typeorm-cli": "^1.0.7"
"typeorm-cli": "^1.0.7",
"xlsx": "^0.18.5",
"redis": "~3.1.2"
}
}

View file

@ -8,6 +8,7 @@ import * as cron from "node-cron";
import error from "./middlewares/error";
import { AppDataSource } from "./database/data-source";
import { RegisterRoutes } from "./routes";
import logMiddleware from "./middlewares/logs";
async function main() {
await AppDataSource.initialize();
@ -21,6 +22,7 @@ async function main() {
);
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(logMiddleware);
app.use("/", express.static("static"));
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,434 @@
import {
Controller,
Get,
Post,
Put,
Delete,
Route,
Security,
Tags,
Body,
Path,
Request,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import { Brackets, Not } from "typeorm";
import HttpSuccess from "../interfaces/http-success";
import HttpError from "../interfaces/http-error";
import HttpStatusCode from "../interfaces/http-status";
import { Development } from "../entities/Development";
import {
CreateDevelopmentHistory,
DevelopmentHistory,
UpdateDevelopmentHistory,
} from "../entities/DevelopmentHistory";
import { EmployeePosType } from "../entities/EmployeePosType";
import { EmployeePosLevel } from "../entities/EmployeePosLevel";
import { RequestWithUser } from "../middlewares/user";
import { setLogDataDiff } from "../interfaces/utils";
import permission from "../interfaces/permission";
@Route("api/v1/development/history/employee")
@Tags("DevelopmentEmployeeHistory")
@Security("bearerAuth")
export class DevelopmentEmployeeHistoryController extends Controller {
private developmentHistoryRepository = AppDataSource.getRepository(DevelopmentHistory);
private developmentRepository = AppDataSource.getRepository(Development);
private posTypeRepository = AppDataSource.getRepository(EmployeePosType);
private posLevelRepository = AppDataSource.getRepository(EmployeePosLevel);
/**
* API list
*
* @summary DEV_00 - list #
*
*/
@Get("org/{year}")
async GetOrgDevelopemt(@Request() request: RequestWithUser, @Path() year: number) {
await new permission().PermissionList(request, "SYS_DEV_HISTORY_EMP");
const type = "EMPLOYEE";
const getOrg = await this.developmentHistoryRepository
.createQueryBuilder("developmentHistory")
.leftJoinAndSelect("developmentHistory.development", "development")
.andWhere("developmentHistory.root IS NOT NULL")
.andWhere(year > 0 ? "development.year LIKE :year" : "1=1", {
year: `${year.toString()}`,
})
.andWhere("developmentHistory.type LIKE :type", {
type: `${type}`,
})
.select("developmentHistory.root")
.groupBy("developmentHistory.root")
.getRawMany();
if (getOrg.length > 0) {
return new HttpSuccess(getOrg.map((x) => x.developmentHistory_root));
}
return new HttpSuccess(getOrg);
}
/**
* API /
*
* @summary DEV_006 - /#6
*
*/
@Post()
async CreateDevelopmentHistory(
@Body() requestBody: CreateDevelopmentHistory,
@Request() request: RequestWithUser,
) {
await new permission().PermissionCreate(request, "SYS_DEV_HISTORY_EMP");
const type = "EMPLOYEE";
const chk_name = await this.developmentHistoryRepository.find({
where: {
citizenId: requestBody.citizenId,
developmentId: requestBody.developmentId,
type: type,
},
});
if (chk_name.length > 0) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประวัติการฝึกอบรม/ดูงาน มีอยู่ในระบบแล้ว");
}
const checkId = await this.developmentRepository.findOne({
where: { id: requestBody.developmentId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรม");
}
if (requestBody.posTypeId != null) {
const checkId = await this.posTypeRepository.findOne({
where: { id: requestBody.posTypeId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
}
}
if (requestBody.posLevelId != null) {
const checkId = await this.posLevelRepository.findOne({
where: { id: requestBody.posLevelId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
}
}
const before = null;
const development = Object.assign(new DevelopmentHistory(), requestBody);
development.type = type;
development.employeePosTypeId = requestBody.posTypeId;
development.employeePosLevelId = requestBody.posLevelId;
development.posTypeId = null;
development.posLevelId = null;
development.createdUserId = request.user.sub;
development.createdFullName = request.user.name;
development.lastUpdateUserId = request.user.sub;
development.lastUpdateFullName = request.user.name;
development.createdAt = new Date();
development.lastUpdatedAt = new Date();
// addLogSequence(request, {
// action: "database",
// status: "success",
// description: "Store DevelopmentHistory.",
// });
await this.developmentHistoryRepository.save(development, { data: request });
setLogDataDiff(request, { before, after: development });
return new HttpSuccess(development.id);
}
/**
* API /
*
* @summary DEV_007 - / #7
*
* @param {string} id Id
*/
@Put("{id}")
async UpdateDevelopmentHistory(
@Path() id: string,
@Body() requestBody: UpdateDevelopmentHistory,
@Request() request: RequestWithUser,
) {
await new permission().PermissionUpdate(request, "SYS_DEV_HISTORY_EMP");
const type = "EMPLOYEE";
const development = await this.developmentHistoryRepository.findOne({
where: { id: id, type: type },
});
if (!development) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้");
}
const chk_name = await this.developmentHistoryRepository.find({
where: {
citizenId: requestBody.citizenId,
developmentId: requestBody.developmentId,
type: type,
id: Not(id),
},
});
if (chk_name.length > 0) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประวัติการฝึกอบรม/ดูงาน มีอยู่ในระบบแล้ว");
}
const checkId = await this.developmentRepository.findOne({
where: { id: requestBody.developmentId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรม");
}
if (requestBody.posTypeId != null) {
const checkId = await this.posTypeRepository.findOne({
where: { id: requestBody.posTypeId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
}
}
if (requestBody.posLevelId != null) {
const checkId = await this.posLevelRepository.findOne({
where: { id: requestBody.posLevelId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
}
}
Object.assign(development, requestBody);
development.type = type;
development.employeePosTypeId = requestBody.posTypeId;
development.employeePosLevelId = requestBody.posLevelId;
development.posTypeId = null;
development.posLevelId = null;
development.lastUpdateUserId = request.user.sub;
development.lastUpdateFullName = request.user.name;
development.lastUpdatedAt = new Date();
// addLogSequence(request, {
// action: "database",
// status: "success",
// description: "Store DevelopmentHistory.",
// });
await this.developmentHistoryRepository.save(development, { data: request });
return new HttpSuccess(development.id);
}
/**
* API /
*
* @summary DEV_008 - / #8
*
* @param {string} id Id
*/
@Delete("{id}")
async DeleteDevelopmentHistory(@Path() id: string, @Request() request: RequestWithUser) {
await new permission().PermissionDelete(request, "SYS_DEV_HISTORY_EMP");
const type = "EMPLOYEE";
const development = await this.developmentHistoryRepository.findOne({
where: { id: id, type: type },
});
if (!development) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้");
}
// addLogSequence(request, {
// action: "remove",
// status: "success",
// description: "Remove DevelopmentHistory.",
// });
await this.developmentHistoryRepository.remove(development, { data: request });
return new HttpSuccess();
}
/**
* API /
*
* @summary DEV_009 - / #9
*
*/
@Post("filter")
async GetDevelopmentHistoryLists(
@Request() request: RequestWithUser,
@Body()
body: {
page: number;
pageSize: number;
keyword?: string;
year?: number;
root: string | null;
},
) {
await new permission().PermissionList(request, "SYS_DEV_HISTORY_EMP");
const type = "EMPLOYEE";
const [development, total] = await AppDataSource.getRepository(DevelopmentHistory)
.createQueryBuilder("developmentHistory")
.leftJoinAndSelect("developmentHistory.development", "development")
.leftJoinAndSelect("developmentHistory.employeePosLevel", "employeePosLevel")
.leftJoinAndSelect("developmentHistory.employeePosType", "employeePosType")
.andWhere(
body.year != 0 && body.year != null && body.year != undefined
? "development.year = :year"
: "1=1",
{ year: body.year },
)
.andWhere(body.root != null ? "developmentHistory.root = :root" : "1=1", { root: body.root })
.andWhere("developmentHistory.type = :type", { type: type })
.andWhere(
new Brackets((qb) => {
qb.where(
body.keyword != null && body.keyword != ""
? "CONCAT(developmentHistory.prefix, developmentHistory.firstName, ' ', developmentHistory.lastName) LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "CONCAT(employeePosType.posTypeShortName,' ',employeePosLevel.posLevelName) LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "developmentHistory.position LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "development.projectName LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "employeePosType.posTypeName LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "employeePosLevel.posLevelName LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "developmentHistory.citizenId LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
);
}),
)
.orderBy("development.year", "DESC")
.addOrderBy("developmentHistory.createdAt", "DESC")
.skip((body.page - 1) * body.pageSize)
.take(body.pageSize)
.getManyAndCount();
const formattedData = development.map((item) => ({
id: item.id,
citizenId: item.citizenId,
fullName:
item.prefix != null && item.firstName != null && item.lastName != null
? `${item?.prefix}${item?.firstName} ${item?.lastName}`
: "",
position: item.position,
year: item.development.year,
posType: item.employeePosType ? item.employeePosType.posTypeName : null,
posLevel:
item.employeePosType && item.employeePosLevel
? `${item.employeePosType.posTypeShortName} ${item.employeePosLevel.posLevelName}`
: null,
projectName: item.development.projectName,
}));
return new HttpSuccess({ data: formattedData, total });
}
/**
* API /
*
* @summary DEV_010 - / #10
*
* @param {string} id Id
*/
@Get("{id}")
async GetDevelopemtHistoryById(@Request() request: RequestWithUser, @Path() id: string) {
let _workflow = await new permission().Workflow(request, id, "SYS_DEV_HISTORY_EMP");
if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_HISTORY_EMP");
const type = "EMPLOYEE";
const getDevelopment = await this.developmentHistoryRepository.findOne({
relations: [
"development",
"development.developmentOthers",
"employeePosLevel",
"employeePosType",
],
where: { id: id, type: type },
order: {
development: {
developmentOthers: {
createdAt: "ASC",
},
},
},
});
if (!getDevelopment) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้");
}
const formattedData = {
rank: getDevelopment.rank,
org: getDevelopment.org,
prefix: getDevelopment.prefix,
firstName: getDevelopment.firstName,
lastName: getDevelopment.lastName,
citizenId: getDevelopment.citizenId,
position: getDevelopment.position,
posLevelId: getDevelopment.employeePosLevelId,
posLevelName:
getDevelopment.employeePosType != null && getDevelopment.employeePosLevel != null
? `${getDevelopment.employeePosType.posTypeShortName} ${getDevelopment.employeePosLevel.posLevelName}`
: null,
posTypeId: getDevelopment.employeePosTypeId,
posTypeName:
getDevelopment.employeePosType != null ? getDevelopment.employeePosType.posTypeName : null,
developmentId: getDevelopment.developmentId,
order: getDevelopment.order,
dateOrder: getDevelopment.dateOrder,
dateHisStart: getDevelopment.dateStart,
dateHisEnd: getDevelopment.dateEnd,
year: getDevelopment.development != null ? getDevelopment.development.year : null,
projectName:
getDevelopment.development != null ? getDevelopment.development.projectName : null,
dateStart: getDevelopment.development != null ? getDevelopment.development.dateStart : null,
dateEnd: getDevelopment.development != null ? getDevelopment.development.dateEnd : null,
totalDate: getDevelopment.development != null ? getDevelopment.development.totalDate : null,
trainingDays: getDevelopment.development != null ? getDevelopment.trainingDays : null,
// addressAcademic:
// getDevelopment.development != null ? getDevelopment.development.addressAcademic : null,
// topicAcademic:
// getDevelopment.development != null ? getDevelopment.development.topicAcademic : null,
dateStudyStart:
getDevelopment.development != null ? getDevelopment.development.dateStudyStart : null,
dateStudyEnd:
getDevelopment.development != null ? getDevelopment.development.dateStudyEnd : null,
academic: getDevelopment.development?.developmentOthers
? getDevelopment.development.developmentOthers.map((dev) => ({
topicAcademic: dev.topicAcademic,
addressAcademic: dev.addressAcademic,
province: dev.provinceActualName,
}))
: [],
};
return new HttpSuccess(formattedData);
}
}

View file

@ -0,0 +1,413 @@
import {
Controller,
Get,
Post,
Put,
Delete,
Route,
Security,
Tags,
Body,
Path,
Request,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import { Brackets, Not } from "typeorm";
import HttpSuccess from "../interfaces/http-success";
import HttpError from "../interfaces/http-error";
import HttpStatusCode from "../interfaces/http-status";
import { Development } from "../entities/Development";
import {
CreateDevelopmentHistory,
DevelopmentHistory,
UpdateDevelopmentHistory,
} from "../entities/DevelopmentHistory";
import { PosType } from "../entities/PosType";
import { PosLevel } from "../entities/PosLevel";
import { RequestWithUser } from "../middlewares/user";
import { setLogDataDiff } from "../interfaces/utils";
import permission from "../interfaces/permission";
@Route("api/v1/development/history/officer")
@Tags("DevelopmentOfficerHistory")
@Security("bearerAuth")
export class DevelopmentOfficerHistoryController extends Controller {
private developmentHistoryRepository = AppDataSource.getRepository(DevelopmentHistory);
private developmentRepository = AppDataSource.getRepository(Development);
private posTypeRepository = AppDataSource.getRepository(PosType);
private posLevelRepository = AppDataSource.getRepository(PosLevel);
/**
* API list
*
* @summary DEV_00 - list #
*
*/
@Get("org/{year}")
async GetOrgDevelopemt(@Request() request: RequestWithUser, @Path() year: number) {
await new permission().PermissionList(request, "SYS_DEV_HISTORY_OFFICER");
const type = "OFFICER";
const getOrg = await this.developmentHistoryRepository
.createQueryBuilder("developmentHistory")
.leftJoinAndSelect("developmentHistory.development", "development")
.andWhere("developmentHistory.root IS NOT NULL")
.andWhere(year > 0 ? "development.year LIKE :year" : "1=1", {
year: `${year.toString()}`,
})
.andWhere("developmentHistory.type LIKE :type", {
type: `${type}`,
})
.select("developmentHistory.root")
.groupBy("developmentHistory.root")
.getRawMany();
if (getOrg.length > 0) {
return new HttpSuccess(getOrg.map((x) => x.developmentHistory_root));
}
return new HttpSuccess(getOrg);
}
/**
* API /
*
* @summary DEV_006 - /#6
*
*/
@Post()
async CreateDevelopmentHistory(
@Body() requestBody: CreateDevelopmentHistory,
@Request() request: RequestWithUser,
) {
await new permission().PermissionCreate(request, "SYS_DEV_HISTORY_OFFICER");
const type = "OFFICER";
const chk_name = await this.developmentHistoryRepository.find({
where: {
citizenId: requestBody.citizenId,
developmentId: requestBody.developmentId,
type: type,
},
});
if (chk_name.length > 0) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประวัติการฝึกอบรม/ดูงาน มีอยู่ในระบบแล้ว");
}
const checkId = await this.developmentRepository.findOne({
where: { id: requestBody.developmentId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรม");
}
if (requestBody.posTypeId != null) {
const checkId = await this.posTypeRepository.findOne({
where: { id: requestBody.posTypeId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
}
}
if (requestBody.posLevelId != null) {
const checkId = await this.posLevelRepository.findOne({
where: { id: requestBody.posLevelId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
}
}
const before = null;
const development = Object.assign(new DevelopmentHistory(), requestBody);
development.type = type;
development.createdUserId = request.user.sub;
development.createdFullName = request.user.name;
development.lastUpdateUserId = request.user.sub;
development.lastUpdateFullName = request.user.name;
development.createdAt = new Date();
development.lastUpdatedAt = new Date();
// addLogSequence(request, {
// action: "database",
// status: "success",
// description: "Store DevelopmentHistory.",
// });
await this.developmentHistoryRepository.save(development, { data: request });
setLogDataDiff(request, { before, after: development });
return new HttpSuccess(development.id);
}
/**
* API /
*
* @summary DEV_007 - / #7
*
* @param {string} id Id
*/
@Put("{id}")
async UpdateDevelopmentHistory(
@Path() id: string,
@Body() requestBody: UpdateDevelopmentHistory,
@Request() request: RequestWithUser,
) {
await new permission().PermissionUpdate(request, "SYS_DEV_HISTORY_OFFICER");
const type = "OFFICER";
const development = await this.developmentHistoryRepository.findOne({
where: { id: id, type: type },
});
if (!development) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้");
}
const chk_name = await this.developmentHistoryRepository.find({
where: {
citizenId: requestBody.citizenId,
developmentId: requestBody.developmentId,
type: type,
id: Not(id),
},
});
if (chk_name.length > 0) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประวัติการฝึกอบรม/ดูงาน มีอยู่ในระบบแล้ว");
}
const checkId = await this.developmentRepository.findOne({
where: { id: requestBody.developmentId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรม");
}
if (requestBody.posTypeId != null) {
const checkId = await this.posTypeRepository.findOne({
where: { id: requestBody.posTypeId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
}
}
if (requestBody.posLevelId != null) {
const checkId = await this.posLevelRepository.findOne({
where: { id: requestBody.posLevelId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
}
}
Object.assign(development, requestBody);
development.type = type;
development.lastUpdateUserId = request.user.sub;
development.lastUpdateFullName = request.user.name;
development.lastUpdatedAt = new Date();
// addLogSequence(request, {
// action: "database",
// status: "success",
// description: "Store DevelopmentHistory.",
// });
await this.developmentHistoryRepository.save(development, { data: request });
return new HttpSuccess(development.id);
}
/**
* API /
*
* @summary DEV_008 - / #8
*
* @param {string} id Id
*/
@Delete("{id}")
async DeleteDevelopmentHistory(@Path() id: string, @Request() request: RequestWithUser) {
await new permission().PermissionDelete(request, "SYS_DEV_HISTORY_OFFICER");
const type = "OFFICER";
const development = await this.developmentHistoryRepository.findOne({
where: { id: id, type: type },
});
if (!development) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้");
}
// addLogSequence(request, {
// action: "database",
// status: "success",
// description: "Store DevelopmentHistory.",
// });
await this.developmentHistoryRepository.remove(development, { data: request });
return new HttpSuccess();
}
/**
* API /
*
* @summary DEV_009 - / #9
*
*/
@Post("filter")
async GetDevelopmentHistoryLists(
@Request() request: RequestWithUser,
@Body()
body: {
page: number;
pageSize: number;
keyword?: string;
year?: number;
root: string | null;
},
) {
await new permission().PermissionList(request, "SYS_DEV_HISTORY_OFFICER");
const type = "OFFICER";
const [development, total] = await AppDataSource.getRepository(DevelopmentHistory)
.createQueryBuilder("developmentHistory")
.leftJoinAndSelect("developmentHistory.development", "development")
.leftJoinAndSelect("developmentHistory.posLevel", "posLevel")
.leftJoinAndSelect("developmentHistory.posType", "posType")
.where("developmentHistory.profileId IS NOT NULL")
.andWhere(
body.year != 0 && body.year != null && body.year != undefined
? "development.year = :year"
: "1=1",
{ year: body.year },
)
// .andWhere(body.root != null && body.root != undefined ? "development.root = :root" : "1=1", {
// root: body.root,
// })
.andWhere(body.root != null ? "developmentHistory.root = :root" : "1=1", { root: body.root })
.andWhere("developmentHistory.type = :type", { type: type })
.andWhere(
new Brackets((qb) => {
qb.where(
body.keyword != null && body.keyword != ""
? "CONCAT(developmentHistory.prefix, developmentHistory.firstName, ' ', developmentHistory.lastName) LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "developmentHistory.position LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "development.projectName LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "posType.posTypeName LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "posLevel.posLevelName LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "developmentHistory.citizenId LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
);
}),
)
.orderBy("development.year", "DESC")
.addOrderBy("developmentHistory.createdAt", "DESC")
.skip((body.page - 1) * body.pageSize)
.take(body.pageSize)
.getManyAndCount();
const formattedData = development.map((item) => ({
id: item.id,
citizenId: item.citizenId,
fullName:
item.prefix == null && item.firstName == null && item.lastName == null
? ""
: `${item?.prefix}${item?.firstName} ${item?.lastName}`,
position: item.position,
year: item.development.year,
root: item.development.root, //test
posType: item.posType ? item.posType.posTypeName : null,
posLevel: item.posLevel ? item.posLevel.posLevelName : null,
posExecutive: item.posExecutive,
projectName: item.development.projectName,
}));
return new HttpSuccess({ data: formattedData, total });
}
/**
* API /
*
* @summary DEV_010 - / #10
*
* @param {string} id Id
*/
@Get("{id}")
async GetDevelopemtHistoryById(@Request() request: RequestWithUser, @Path() id: string) {
let _workflow = await new permission().Workflow(request, id, "SYS_DEV_HISTORY_OFFICER");
if (_workflow == false)
await new permission().PermissionGet(request, "SYS_DEV_HISTORY_OFFICER");
const type = "OFFICER";
const getDevelopment = await this.developmentHistoryRepository.findOne({
relations: ["development", "development.developmentOthers", "posLevel", "posType"],
where: { id: id, type: type },
order: {
development: {
developmentOthers: {
createdAt: "ASC",
},
},
},
});
if (!getDevelopment) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้");
}
const formattedData = {
rank: getDevelopment.rank,
org: getDevelopment.org,
prefix: getDevelopment.prefix,
firstName: getDevelopment.firstName,
lastName: getDevelopment.lastName,
citizenId: getDevelopment.citizenId,
position: getDevelopment.position,
posLevelId: getDevelopment.posLevelId,
posLevelName: getDevelopment.posLevel != null ? getDevelopment.posLevel.posLevelName : null,
posTypeId: getDevelopment.posTypeId,
posTypeName: getDevelopment.posType != null ? getDevelopment.posType.posTypeName : null,
posExecutive: getDevelopment.posExecutive,
developmentId: getDevelopment.developmentId,
order: getDevelopment.order,
dateOrder: getDevelopment.dateOrder,
dateHisStart: getDevelopment.dateStart,
dateHisEnd: getDevelopment.dateEnd,
year: getDevelopment.development != null ? getDevelopment.development.year : null,
projectName:
getDevelopment.development != null ? getDevelopment.development.projectName : null,
dateStart: getDevelopment.development != null ? getDevelopment.development.dateStart : null,
dateEnd: getDevelopment.development != null ? getDevelopment.development.dateEnd : null,
totalDate: getDevelopment.development != null ? getDevelopment.development.totalDate : null,
trainingDays: getDevelopment.development != null ? getDevelopment.trainingDays : null,
// addressAcademic:
// getDevelopment.development != null ? getDevelopment.development.addressAcademic : null,
// topicAcademic:
// getDevelopment.development != null ? getDevelopment.development.topicAcademic : null,
dateStudyStart:
getDevelopment.development != null ? getDevelopment.development.dateStudyStart : null,
dateStudyEnd:
getDevelopment.development != null ? getDevelopment.development.dateStudyEnd : null,
academic: getDevelopment.development?.developmentOthers
? getDevelopment.development.developmentOthers.map((dev) => ({
topicAcademic: dev.topicAcademic,
addressAcademic: dev.addressAcademic,
province: dev.provinceActualName,
}))
: [],
};
return new HttpSuccess(formattedData);
}
}

View file

@ -0,0 +1,805 @@
import {
Controller,
Get,
Post,
Put,
Delete,
Route,
Security,
Tags,
Body,
Path,
Request,
Query,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import { Brackets } from "typeorm";
import HttpSuccess from "../interfaces/http-success";
import HttpError from "../interfaces/http-error";
import HttpStatusCode from "../interfaces/http-status";
import {
CreateDevelopmentScholarship,
DevelopmentScholarship,
UpdateDevelopmentScholarship,
UpdateDevelopmentScholarshipUser,
} from "../entities/DevelopmentScholarship";
import { PosType } from "../entities/PosType";
import { PosLevel } from "../entities/PosLevel";
import CallAPI from "../interfaces/call-api";
import { RequestWithUser } from "../middlewares/user";
import { setLogDataDiff } from "../interfaces/utils";
import permission from "../interfaces/permission";
@Route("api/v1/development/scholarship")
@Tags("DevelopmentScholarship")
@Security("bearerAuth")
export class DevelopmentScholarshipController extends Controller {
private developmentScholarshipRepository = AppDataSource.getRepository(DevelopmentScholarship);
private posTypeRepository = AppDataSource.getRepository(PosType);
private posLevelRepository = AppDataSource.getRepository(PosLevel);
/**
* API /
*
* @summary DEV_011 - /#11
*
*/
@Post()
async CreateDevelopmentScholarship(
@Body() requestBody: CreateDevelopmentScholarship,
@Request() request: RequestWithUser,
) {
await new permission().PermissionCreate(request, "SYS_DEV_SCHOLARSHIP");
if (requestBody.posTypeId != null) {
const checkId = await this.posTypeRepository.findOne({
where: { id: requestBody.posTypeId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
}
}
if (requestBody.posLevelId != null) {
const checkId = await this.posLevelRepository.findOne({
where: { id: requestBody.posLevelId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
}
}
const before = null;
const development = Object.assign(new DevelopmentScholarship(), requestBody);
development.createdUserId = request.user.sub;
development.createdFullName = request.user.name;
development.lastUpdateUserId = request.user.sub;
development.lastUpdateFullName = request.user.name;
development.createdAt = new Date();
development.lastUpdatedAt = new Date();
await this.developmentScholarshipRepository.save(development, { data: request });
setLogDataDiff(request, { before, after: development });
return new HttpSuccess(development.id);
}
/**
* API /
*
* @summary DEV_012 - / #12
*
* @param {string} id Id
*/
@Put("{id}")
async UpdateDevelopmentScholarship(
@Path() id: string,
@Body() requestBody: UpdateDevelopmentScholarship,
@Request() request: RequestWithUser,
) {
await new permission().PermissionUpdate(request, "SYS_DEV_SCHOLARSHIP");
const development = await this.developmentScholarshipRepository.findOne({
where: { id: id },
});
if (!development) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
}
if (requestBody.posTypeId != null) {
const checkId = await this.posTypeRepository.findOne({
where: { id: requestBody.posTypeId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
}
}
if (requestBody.posLevelId != null) {
const checkId = await this.posLevelRepository.findOne({
where: { id: requestBody.posLevelId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
}
}
const before = structuredClone(development);
Object.assign(development, requestBody);
development.lastUpdateUserId = request.user.sub;
development.lastUpdateFullName = request.user.name;
development.lastUpdatedAt = new Date();
await this.developmentScholarshipRepository.save(development, { data: request });
setLogDataDiff(request, { before, after: development });
return new HttpSuccess(development.id);
}
/**
* API /
*
* @summary DEV_013 - / #13
*
* @param {string} id Id
*/
@Delete("{id}")
async DeleteDevelopmentScholarship(@Path() id: string, @Request() request: RequestWithUser) {
await new permission().PermissionDelete(request, "SYS_DEV_SCHOLARSHIP");
const development = await this.developmentScholarshipRepository.findOne({
where: { id: id },
});
if (!development) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
}
await this.developmentScholarshipRepository.remove(development, { data: request });
return new HttpSuccess();
}
/**
* API /
*
* @summary DEV_014 - / #14
*
*/
@Get()
async GetDevelopmentScholarshipLists(
@Request() request: RequestWithUser,
@Query("page") page: number = 1,
@Query("pageSize") pageSize: number = 10,
@Query("keyword") keyword?: string,
@Query("year") year?: number,
@Query("scholarshipType") scholarshipType?: string,
) {
let _data = await new permission().PermissionOrgList(request, "SYS_DEV_SCHOLARSHIP");
await new CallAPI()
.PostData(request, "/org/finddna", _data)
.then((x) => {
_data = x;
})
.catch((x) => {});
const [development, total] = await AppDataSource.getRepository(DevelopmentScholarship)
.createQueryBuilder("developmentScholarship")
.leftJoinAndSelect("developmentScholarship.posLevel", "posLevel")
.leftJoinAndSelect("developmentScholarship.posType", "posType")
.andWhere(
year !== 0 && year != null && year != undefined
? "developmentScholarship.scholarshipYear = :scholarshipYear"
: "1=1",
{ scholarshipYear: year },
)
.andWhere(
scholarshipType != null && scholarshipType != undefined
? "developmentScholarship.scholarshipType = :scholarshipType"
: "1=1",
{ scholarshipType: scholarshipType },
)
.andWhere(
new Brackets((qb) => {
qb.where(
keyword != null && keyword != ""
? `CONCAT(developmentScholarship.prefix, developmentScholarship.firstName," ",developmentScholarship.lastName) like '%${keyword}%'`
: "1=1",
{
keyword: `%${keyword}%`,
},
)
.orWhere(
keyword != null && keyword != ""
? "developmentScholarship.citizenId LIKE :keyword"
: "1=1",
{
keyword: `%${keyword}%`,
},
)
.orWhere(
keyword != null && keyword != ""
? "developmentScholarship.position LIKE :keyword"
: "1=1",
{
keyword: `%${keyword}%`,
},
)
.orWhere(
keyword != null && keyword != ""
? "developmentScholarship.posExecutive LIKE :keyword"
: "1=1",
{
keyword: `%${keyword}%`,
},
)
.orWhere(
keyword != null && keyword != "" ? "posType.posTypeName LIKE :keyword" : "1=1",
{
keyword: `%${keyword}%`,
},
)
.orWhere(
keyword != null && keyword != "" ? "posLevel.posLevelName LIKE :keyword" : "1=1",
{
keyword: `%${keyword}%`,
},
);
}),
)
.andWhere(
_data.root != undefined && _data.root != null
? _data.root[0] != null
? `developmentScholarship.rootDnaId IN (:...root)`
: `developmentScholarship.rootDnaId is null`
: "1=1",
{
root: _data.root,
},
)
.orderBy("developmentScholarship.scholarshipYear", "DESC")
.addOrderBy("developmentScholarship.createdAt", "DESC")
.skip((page - 1) * pageSize)
.take(pageSize)
.getManyAndCount();
const formattedData = development.map((item) => ({
id: item.id,
year: item.scholarshipYear,
citizenId: item.citizenId,
fullName: item.prefix + item.firstName + " " + item.lastName,
position: item.position,
posType: item.posType ? item.posType.posTypeName : null,
posLevel: item.posLevel ? item.posLevel.posLevelName : null,
posExecutive: item.posExecutive,
status: item.status,
}));
return new HttpSuccess({ data: formattedData, total });
}
/**
* API /
*
* @summary DEV_015 - / #15
*
* @param {string} id Id
*/
@Get("{id}")
async GetDevelopemtScholarshipById(@Request() request: RequestWithUser, @Path() id: string) {
//await new permission().PermissionGet(request, "SYS_DEV_SCHOLARSHIP"); //USER
const getDevelopment = await this.developmentScholarshipRepository.findOne({
relations: ["posLevel", "posType", "posLevelguarantor", "posTypeguarantor"],
where: { id: id },
});
if (!getDevelopment) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
}
const formattedData = {
rootDnaId: getDevelopment.rootDnaId ? getDevelopment.rootDnaId : null,
rootId: getDevelopment.rootId ? getDevelopment.rootId : null,
root: getDevelopment.root ? getDevelopment.root : null,
org: getDevelopment.org ? getDevelopment.org : null,
orgRootShortName: getDevelopment.orgRootShortName ? getDevelopment.orgRootShortName : null,
orgRevisionId: getDevelopment.orgRevisionId ? getDevelopment.orgRevisionId : null,
rank: getDevelopment.rank ? getDevelopment.rank : null,
prefix: getDevelopment.prefix ? getDevelopment.prefix : null,
firstName: getDevelopment.firstName ? getDevelopment.firstName : null,
lastName: getDevelopment.lastName ? getDevelopment.lastName : null,
citizenId: getDevelopment.citizenId ? getDevelopment.citizenId : null,
position: getDevelopment.position ? getDevelopment.position : null,
posExecutive: getDevelopment.posExecutive ? getDevelopment.posExecutive : null,
posLevelId: getDevelopment.posLevelId ? getDevelopment.posLevelId : null,
posLevelName: getDevelopment.posLevel?.posLevelName
? getDevelopment.posLevel?.posLevelName
: null,
posTypeId: getDevelopment.posTypeId ? getDevelopment.posTypeId : null,
posTypeName: getDevelopment.posType?.posTypeName ? getDevelopment.posType?.posTypeName : null,
guarantorRootDnaId: getDevelopment.guarantorRootDnaId
? getDevelopment.guarantorRootDnaId
: null,
guarantorRootId: getDevelopment.guarantorRootId ? getDevelopment.guarantorRootId : null,
guarantorRoot: getDevelopment.guarantorRoot ? getDevelopment.guarantorRoot : null,
guarantorOrg: getDevelopment.guarantorOrg ? getDevelopment.guarantorOrg : null,
guarantorOrgRootShortName: getDevelopment.guarantorOrgRootShortName
? getDevelopment.guarantorOrgRootShortName
: null,
guarantorOrgRevisionId: getDevelopment.guarantorOrgRevisionId
? getDevelopment.guarantorOrgRevisionId
: null,
guarantorRank: getDevelopment.guarantorRank ? getDevelopment.guarantorRank : null,
guarantorPrefix: getDevelopment.guarantorPrefix ? getDevelopment.guarantorPrefix : null,
guarantorFirstName: getDevelopment.guarantorFirstName
? getDevelopment.guarantorFirstName
: null,
guarantorLastName: getDevelopment.guarantorLastName ? getDevelopment.guarantorLastName : null,
guarantorCitizenId: getDevelopment.guarantorCitizenId
? getDevelopment.guarantorCitizenId
: null,
guarantorPosition: getDevelopment.guarantorPosition ? getDevelopment.guarantorPosition : null,
guarantorPosExecutive: getDevelopment.guarantorPosExecutive
? getDevelopment.guarantorPosExecutive
: null,
posLevelguarantorId: getDevelopment.posLevelguarantorId
? getDevelopment.posLevelguarantorId
: null,
posLevelguarantorName: getDevelopment.posLevelguarantor?.posLevelName
? getDevelopment.posLevelguarantor?.posLevelName
: null,
posTypeguarantorId: getDevelopment.posTypeguarantorId
? getDevelopment.posTypeguarantorId
: null,
posTypeguarantorName: getDevelopment.posTypeguarantor?.posTypeName
? getDevelopment.posTypeguarantor?.posTypeName
: null,
scholarshipYear: getDevelopment.scholarshipYear ? getDevelopment.scholarshipYear : null,
budgetSource: getDevelopment.budgetSource ? getDevelopment.budgetSource : null,
budgetApprove: getDevelopment.budgetApprove ? getDevelopment.budgetApprove : null,
bookNo: getDevelopment.bookNo ? getDevelopment.bookNo : null,
bookNoDate: getDevelopment.bookNoDate ? getDevelopment.bookNoDate : null,
bookApproveDate: getDevelopment.bookApproveDate ? getDevelopment.bookApproveDate : null,
useOfficialTime: getDevelopment.useOfficialTime ? getDevelopment.useOfficialTime : null,
changeDetail: getDevelopment.changeDetail ? getDevelopment.changeDetail : null,
scholarshipType: getDevelopment.scholarshipType ? getDevelopment.scholarshipType : null,
fundType: getDevelopment.fundType ? getDevelopment.fundType : null,
contractNo: getDevelopment.contractNo ? getDevelopment.contractNo : null,
contractDate: getDevelopment.contractDate ? getDevelopment.contractDate : null,
reportBackNo: getDevelopment.reportBackNo ? getDevelopment.reportBackNo : null,
reportBackNoDate: getDevelopment.reportBackNoDate ? getDevelopment.reportBackNoDate : null,
reportBackDate: getDevelopment.reportBackDate ? getDevelopment.reportBackDate : null,
degreeLevel: getDevelopment.degreeLevel ? getDevelopment.degreeLevel : null,
course: getDevelopment.course ? getDevelopment.course : null,
field: getDevelopment.field ? getDevelopment.field : null,
faculty: getDevelopment.faculty ? getDevelopment.faculty : null,
educationalInstitution: getDevelopment.educationalInstitution
? getDevelopment.educationalInstitution
: null,
startDate: getDevelopment.startDate ? getDevelopment.startDate : null,
endDate: getDevelopment.endDate ? getDevelopment.endDate : null,
studyPlace: getDevelopment.studyPlace ? getDevelopment.studyPlace : null,
studyTopic: getDevelopment.studyTopic ? getDevelopment.studyTopic : null,
studyStartDate: getDevelopment.studyStartDate ? getDevelopment.studyStartDate : null,
studyEndDate: getDevelopment.studyEndDate ? getDevelopment.studyEndDate : null,
studyCountry: getDevelopment.studyCountry ? getDevelopment.studyCountry : null,
studyAbroadTopic: getDevelopment.studyAbroadTopic ? getDevelopment.studyAbroadTopic : null,
studyAbroadStartDate: getDevelopment.studyAbroadStartDate
? getDevelopment.studyAbroadStartDate
: null,
studyAbroadEndDate: getDevelopment.studyAbroadEndDate
? getDevelopment.studyAbroadEndDate
: null,
totalPeriod: getDevelopment.totalPeriod ? getDevelopment.totalPeriod : null,
status: getDevelopment.status ? getDevelopment.status : null,
profileId: getDevelopment.profileId ? getDevelopment.profileId : null,
planType: getDevelopment.planType ? getDevelopment.planType : null,
isNoUseBudget: getDevelopment.isNoUseBudget ? getDevelopment.isNoUseBudget : null,
};
return new HttpSuccess(formattedData);
}
/**
* API /
*
* @summary DEV_012 - / #12
*
* @param {string} id Id
*/
@Put("admin/{id}")
async UpdateDevelopmentScholarshipAdminById(
@Path() id: string,
@Body() requestBody: UpdateDevelopmentScholarship,
@Request() request: RequestWithUser,
) {
await new permission().PermissionUpdate(request, "SYS_DEV_SCHOLARSHIP");
const development = await this.developmentScholarshipRepository.findOne({
where: { id: id },
});
if (!development) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
}
if (requestBody.posTypeId != null) {
const checkId = await this.posTypeRepository.findOne({
where: { id: requestBody.posTypeId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
}
}
if (requestBody.posLevelId != null) {
const checkId = await this.posLevelRepository.findOne({
where: { id: requestBody.posLevelId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
}
}
const before = structuredClone(development);
Object.assign(development, requestBody);
development.lastUpdateUserId = request.user.sub;
development.lastUpdateFullName = request.user.name;
development.lastUpdatedAt = new Date();
await this.developmentScholarshipRepository.save(development, { data: request });
setLogDataDiff(request, { before, after: development });
return new HttpSuccess(development.id);
}
/**
* API / ADMIN
*
* @summary DEV_015 - / #15 ADMIN
*
* @param {string} id Id ADMIN
*/
@Get("admin/{id}")
async GetDevelopemtScholarshipAdminById(@Request() request: RequestWithUser, @Path() id: string) {
let _workflow = await new permission().Workflow(request, id, "SYS_DEV_SCHOLARSHIP");
if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_SCHOLARSHIP");
const getDevelopment = await this.developmentScholarshipRepository.findOne({
relations: ["posLevel", "posType", "posLevelguarantor", "posTypeguarantor"],
where: { id: id },
});
if (!getDevelopment) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
}
const formattedData = {
rootDnaId: getDevelopment.rootDnaId ? getDevelopment.rootDnaId : null,
rootId: getDevelopment.rootId ? getDevelopment.rootId : null,
root: getDevelopment.root ? getDevelopment.root : null,
org: getDevelopment.org ? getDevelopment.org : null,
orgRootShortName: getDevelopment.orgRootShortName ? getDevelopment.orgRootShortName : null,
orgRevisionId: getDevelopment.orgRevisionId ? getDevelopment.orgRevisionId : null,
rank: getDevelopment.rank ? getDevelopment.rank : null,
prefix: getDevelopment.prefix ? getDevelopment.prefix : null,
firstName: getDevelopment.firstName ? getDevelopment.firstName : null,
lastName: getDevelopment.lastName ? getDevelopment.lastName : null,
citizenId: getDevelopment.citizenId ? getDevelopment.citizenId : null,
position: getDevelopment.position ? getDevelopment.position : null,
posExecutive: getDevelopment.posExecutive ? getDevelopment.posExecutive : null,
posLevelId: getDevelopment.posLevelId ? getDevelopment.posLevelId : null,
posLevelName: getDevelopment.posLevel?.posLevelName
? getDevelopment.posLevel?.posLevelName
: null,
posTypeId: getDevelopment.posTypeId ? getDevelopment.posTypeId : null,
posTypeName: getDevelopment.posType?.posTypeName ? getDevelopment.posType?.posTypeName : null,
guarantorRootDnaId: getDevelopment.guarantorRootDnaId
? getDevelopment.guarantorRootDnaId
: null,
guarantorRootId: getDevelopment.guarantorRootId ? getDevelopment.guarantorRootId : null,
guarantorRoot: getDevelopment.guarantorRoot ? getDevelopment.guarantorRoot : null,
guarantorOrg: getDevelopment.guarantorOrg ? getDevelopment.guarantorOrg : null,
guarantorOrgRootShortName: getDevelopment.guarantorOrgRootShortName
? getDevelopment.guarantorOrgRootShortName
: null,
guarantorOrgRevisionId: getDevelopment.guarantorOrgRevisionId
? getDevelopment.guarantorOrgRevisionId
: null,
guarantorRank: getDevelopment.guarantorRank ? getDevelopment.guarantorRank : null,
guarantorPrefix: getDevelopment.guarantorPrefix ? getDevelopment.guarantorPrefix : null,
guarantorFirstName: getDevelopment.guarantorFirstName
? getDevelopment.guarantorFirstName
: null,
guarantorLastName: getDevelopment.guarantorLastName ? getDevelopment.guarantorLastName : null,
guarantorCitizenId: getDevelopment.guarantorCitizenId
? getDevelopment.guarantorCitizenId
: null,
guarantorPosition: getDevelopment.guarantorPosition ? getDevelopment.guarantorPosition : null,
guarantorPosExecutive: getDevelopment.guarantorPosExecutive
? getDevelopment.guarantorPosExecutive
: null,
posLevelguarantorId: getDevelopment.posLevelguarantorId
? getDevelopment.posLevelguarantorId
: null,
posLevelguarantorName: getDevelopment.posLevelguarantor?.posLevelName
? getDevelopment.posLevelguarantor?.posLevelName
: null,
posTypeguarantorId: getDevelopment.posTypeguarantorId
? getDevelopment.posTypeguarantorId
: null,
posTypeguarantorName: getDevelopment.posTypeguarantor?.posTypeName
? getDevelopment.posTypeguarantor?.posTypeName
: null,
scholarshipYear: getDevelopment.scholarshipYear ? getDevelopment.scholarshipYear : null,
budgetSource: getDevelopment.budgetSource ? getDevelopment.budgetSource : null,
budgetApprove: getDevelopment.budgetApprove ? getDevelopment.budgetApprove : null,
bookNo: getDevelopment.bookNo ? getDevelopment.bookNo : null,
bookNoDate: getDevelopment.bookNoDate ? getDevelopment.bookNoDate : null,
bookApproveDate: getDevelopment.bookApproveDate ? getDevelopment.bookApproveDate : null,
useOfficialTime: getDevelopment.useOfficialTime ? getDevelopment.useOfficialTime : null,
changeDetail: getDevelopment.changeDetail ? getDevelopment.changeDetail : null,
scholarshipType: getDevelopment.scholarshipType ? getDevelopment.scholarshipType : null,
fundType: getDevelopment.fundType ? getDevelopment.fundType : null,
contractNo: getDevelopment.contractNo ? getDevelopment.contractNo : null,
contractDate: getDevelopment.contractDate ? getDevelopment.contractDate : null,
reportBackNo: getDevelopment.reportBackNo ? getDevelopment.reportBackNo : null,
reportBackNoDate: getDevelopment.reportBackNoDate ? getDevelopment.reportBackNoDate : null,
reportBackDate: getDevelopment.reportBackDate ? getDevelopment.reportBackDate : null,
degreeLevel: getDevelopment.degreeLevel ? getDevelopment.degreeLevel : null,
course: getDevelopment.course ? getDevelopment.course : null,
field: getDevelopment.field ? getDevelopment.field : null,
faculty: getDevelopment.faculty ? getDevelopment.faculty : null,
educationalInstitution: getDevelopment.educationalInstitution
? getDevelopment.educationalInstitution
: null,
startDate: getDevelopment.startDate ? getDevelopment.startDate : null,
endDate: getDevelopment.endDate ? getDevelopment.endDate : null,
studyPlace: getDevelopment.studyPlace ? getDevelopment.studyPlace : null,
studyTopic: getDevelopment.studyTopic ? getDevelopment.studyTopic : null,
studyStartDate: getDevelopment.studyStartDate ? getDevelopment.studyStartDate : null,
studyEndDate: getDevelopment.studyEndDate ? getDevelopment.studyEndDate : null,
studyCountry: getDevelopment.studyCountry ? getDevelopment.studyCountry : null,
studyAbroadTopic: getDevelopment.studyAbroadTopic ? getDevelopment.studyAbroadTopic : null,
studyAbroadStartDate: getDevelopment.studyAbroadStartDate
? getDevelopment.studyAbroadStartDate
: null,
studyAbroadEndDate: getDevelopment.studyAbroadEndDate
? getDevelopment.studyAbroadEndDate
: null,
totalPeriod: getDevelopment.totalPeriod ? getDevelopment.totalPeriod : null,
status: getDevelopment.status ? getDevelopment.status : null,
profileId: getDevelopment.profileId ? getDevelopment.profileId : null,
planType: getDevelopment.planType ? getDevelopment.planType : null,
isNoUseBudget: getDevelopment.isNoUseBudget ? getDevelopment.isNoUseBudget : null,
budgetSourceOther: getDevelopment.budgetSourceOther ? getDevelopment.budgetSourceOther : null,
};
return new HttpSuccess(formattedData);
}
/**
* API user
*
* @summary DEV_0 - user #
*
* @param {string} profileId profileId
*/
@Get("user/{profileId}")
async GetDevelopemtScholarshipUserById(
@Path() profileId: string,
@Query("type") type?: string | null,
@Query("year") year?: number | null,
) {
const getDevelopment = await AppDataSource.getRepository(DevelopmentScholarship)
.createQueryBuilder("developmentScholarship")
.andWhere("developmentScholarship.profileId = :profileId", { profileId: profileId })
.andWhere(
year !== 0 && year != null && year != undefined
? "developmentScholarship.scholarshipYear = :scholarshipYear"
: "1=1",
{ scholarshipYear: year },
)
.andWhere(
type != null && type != undefined
? "developmentScholarship.scholarshipType = :scholarshipType"
: "1=1",
{ scholarshipType: type },
)
.select(["id", "scholarshipYear", "scholarshipYear", "scholarshipType", "fundType"])
.orderBy("developmentScholarship.createdAt", "DESC")
.getRawMany();
return new HttpSuccess(getDevelopment);
}
/**
* API admin
*
* @summary DEV_0 - admin #
*
* @param {string} id id
*/
@Get("admin/detail/{id}")
async GetDevelopemtScholarshipUserDetailAdminById(
@Request() request: RequestWithUser,
@Path() id: string,
) {
let _workflow = await new permission().Workflow(request, id, "SYS_DEV_SCHOLARSHIP");
if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_SCHOLARSHIP");
const getDevelopment = await this.developmentScholarshipRepository.findOne({
where: { id: id },
select: [
"id",
"scholarshipYear",
"scholarshipType",
"fundType",
"bookNumber",
"bookDate",
"governmentDate",
"governmentEndDate",
"isGraduated",
"graduatedDate",
"graduatedReason",
"org",
],
});
if (!getDevelopment) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
}
return new HttpSuccess(getDevelopment);
}
/**
* API user
*
* @summary DEV_0 - user #
*
* @param {string} id id
*/
@Get("user/detail/{id}")
async GetDevelopemtScholarshipUserDetailById(@Path() id: string) {
const getDevelopment = await this.developmentScholarshipRepository.findOne({
where: { id: id },
select: [
"id",
"scholarshipYear",
"scholarshipType",
"fundType",
"bookNumber",
"bookDate",
"governmentDate",
"governmentEndDate",
"isGraduated",
"graduatedDate",
"graduatedReason",
"org",
],
});
if (!getDevelopment) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
}
return new HttpSuccess(getDevelopment);
}
/**
* API user
*
* @summary DEV_015 - user #15
*
* @param {string} id
*/
@Put("user/detail/{id}")
async UpdateDevelopemtScholarshipUserById(
@Path() id: string,
@Body() requestBody: UpdateDevelopmentScholarshipUser,
@Request() request: RequestWithUser,
) {
// await new permission().PermissionUpdate(request, "SYS_DEV_SCHOLARSHIP");
const getDevelopment = await this.developmentScholarshipRepository.findOne({
where: { id: id },
});
if (!getDevelopment) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
}
const before = structuredClone(getDevelopment);
Object.assign(getDevelopment, requestBody);
getDevelopment.lastUpdateUserId = request.user.sub;
getDevelopment.lastUpdateFullName = request.user.name;
getDevelopment.lastUpdatedAt = new Date();
await this.developmentScholarshipRepository.save(getDevelopment, { data: request });
setLogDataDiff(request, { before, after: getDevelopment });
return new HttpSuccess(getDevelopment.id);
}
/**
* API admin
*
* @summary DEV_015 - admin #15
*
* @param {string} id
*/
@Put("admin/detail/{id}")
async UpdateDevelopemtScholarshipAdminById(
@Path() id: string,
@Body() requestBody: UpdateDevelopmentScholarshipUser,
@Request() request: RequestWithUser,
) {
await new permission().PermissionUpdate(request, "SYS_DEV_SCHOLARSHIP");
const getDevelopment = await this.developmentScholarshipRepository.findOne({
where: { id: id },
});
if (!getDevelopment) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
}
const before = structuredClone(getDevelopment);
Object.assign(getDevelopment, requestBody);
getDevelopment.lastUpdateUserId = request.user.sub;
getDevelopment.lastUpdateFullName = request.user.name;
getDevelopment.lastUpdatedAt = new Date();
await this.developmentScholarshipRepository.save(getDevelopment, { data: request });
setLogDataDiff(request, { before, after: getDevelopment });
return new HttpSuccess(getDevelopment.id);
}
/**
* API
*
* @summary DEV_0 - #
*
* @param {string} id Id
* @param {string} status status
*/
@Get("status/{id}/{status}")
async ChangeStatusDevelopemtScholarshipById(
@Path() id: string,
@Path() status: string,
@Request() request: RequestWithUser,
) {
const getDevelopment = await this.developmentScholarshipRepository.findOne({
where: { id: id },
});
if (!getDevelopment) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
}
const _status = status.trim().toUpperCase();
getDevelopment.status = _status;
getDevelopment.lastUpdateUserId = request.user.sub;
getDevelopment.lastUpdateFullName = request.user.name;
let scholarshipType = "";
if (_status == "GRADUATE") {
if (getDevelopment.scholarshipType != null) {
switch (getDevelopment.scholarshipType.trim().toUpperCase()) {
case "DOMESTICE":
scholarshipType = "การศึกษาในประเทศ";
break;
case "NOABROAD":
scholarshipType =
"ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่ไม่มีการไปต่างประเทศ)";
break;
case "ABROAD":
scholarshipType =
"ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่มีการไปต่างประเทศ)";
break;
case "EXECUTIVE":
scholarshipType =
"ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรประเภทนักบริหาร)";
break;
default:
break;
}
}
let profileEdu = await new CallAPI()
.PostData(request, "/org/profile/educations", {
profileId: getDevelopment.profileId,
institute: getDevelopment.educationalInstitution,
startDate: getDevelopment.startDate,
endDate: getDevelopment.endDate,
finishDate: null,
isEducation: false,
degree: null,
field: getDevelopment.field,
fundName: scholarshipType,
gpa: null,
country: getDevelopment.studyCountry,
other: null,
duration: getDevelopment.totalPeriod,
durationYear: 0,
note: null,
educationLevel: getDevelopment.degreeLevel,
educationLevelId: null,
isDate: false,
positionPath: null,
positionPathId: null,
})
.then(async (x) => {
await this.developmentScholarshipRepository.save(getDevelopment, { data: request });
})
.catch((error) => {
console.error("ไม่สามารถบันทึกลงทะเบียนประวัติได้");
});
} else if (_status == "NOTGRADUATE") {
getDevelopment.status = _status;
getDevelopment.lastUpdateUserId = request.user.sub;
getDevelopment.lastUpdateFullName = request.user.name;
getDevelopment.lastUpdatedAt = new Date();
await this.developmentScholarshipRepository.save(getDevelopment, { data: request });
} else {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบสถานะนี้ในระบบ");
}
return new HttpSuccess();
}
}

View file

@ -1,4 +1,4 @@
import { Controller, Get, Post, Put, Delete, Patch, Route, Security, Tags } from "tsoa";
import { Controller, Get, Route, Security, Tags } from "tsoa";
@Route("/hello")
@Tags("Test")

View file

@ -0,0 +1,234 @@
import {
Controller,
Post,
Put,
Delete,
Route,
Security,
Tags,
Body,
Path,
Request,
SuccessResponse,
Response,
Get,
Query,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success";
import HttpStatusCode from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
import { Not } from "typeorm";
import { CreatePortfolio, Portfolio } from "../entities/Portfolio";
import { RequestWithUser } from "../middlewares/user";
import { setLogDataDiff } from "../interfaces/utils";
import { Brackets } from "typeorm";
@Route("api/v1/development/portfolio")
@Tags("Portfolio")
@Security("bearerAuth")
@Response(
HttpStatusCode.INTERNAL_SERVER_ERROR,
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
)
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
export class PortfolioController extends Controller {
private portfolioRepository = AppDataSource.getRepository(Portfolio);
/**
* API list
*
* @summary ORG_058 - CRUD (ADMIN) #62
*
*/
@Get()
async GetResult(@Request() request: RequestWithUser) {
const _portfolio = await this.portfolioRepository.find({
where: { createdUserId: request.user.sub },
select: [
"id",
"name",
"detail",
"createdAt",
"lastUpdatedAt",
"createdFullName",
"lastUpdateFullName",
],
order: { createdAt: "DESC" },
});
return new HttpSuccess(_portfolio);
}
/**
* API list
*
* @summary list
*
*/
@Get("user")
async GetResultForEva(@Request() request: RequestWithUser) {
const _portfolio = await this.portfolioRepository.find({
where: { createdUserId: request.user.sub },
select: [
"id",
"name",
"detail",
"createdAt",
"lastUpdatedAt",
"createdFullName",
"lastUpdateFullName",
],
order: { createdAt: "DESC" },
});
return new HttpSuccess(_portfolio);
}
/**
* API
*
* @summary ORG_058 - CRUD (ADMIN) #62
*
* @param {string} id Id
*/
@Get("{id}")
async GetById(@Path() id: string, @Request() request: RequestWithUser) {
const _portfolio = await this.portfolioRepository.findOne({
where: { id: id, createdUserId: request.user.sub },
select: ["id", "name", "detail"],
});
if (!_portfolio) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผลงานนี้");
}
return new HttpSuccess(_portfolio);
}
/**
* API ..7/..1
*
* @summary ..7/..1
*
*/
@Get("kk1/{keycloak}")
async GetPortfolio(@Path() keycloak: string, @Request() request: RequestWithUser) {
const _portfolio = await this.portfolioRepository.find({
where: { createdUserId: keycloak },
select: [
"name",
"createdAt"
],
order: { createdAt: "DESC" },
});
const result =
_portfolio.map(x => ({
name: x.name,
year: x.createdAt.getFullYear() > 2500
? x.createdAt.getFullYear()
: x.createdAt.getFullYear()+543
}));
return new HttpSuccess(result);
}
/**
* API body
*
* @summary ORG_058 - CRUD (ADMIN) #62
*
*/
@Post()
async Post(
@Body()
requestBody: CreatePortfolio,
@Request() request: RequestWithUser,
) {
const _portfolio = Object.assign(new Portfolio(), requestBody);
if (!_portfolio) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผลงานนี้");
}
const checkName = await this.portfolioRepository.findOne({
where: { name: requestBody.name, createdUserId: request.user.sub },
});
if (checkName) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
}
const before = null;
_portfolio.createdUserId = request.user.sub;
_portfolio.createdFullName = request.user.name;
_portfolio.lastUpdateUserId = request.user.sub;
_portfolio.lastUpdateFullName = request.user.name;
_portfolio.createdAt = new Date();
_portfolio.lastUpdatedAt = new Date();
// addLogSequence(request, {
// action: "database",
// status: "success",
// description: "Store Portfolio.",
// });
await this.portfolioRepository.save(_portfolio, { data: request });
setLogDataDiff(request, { before, after: _portfolio });
return new HttpSuccess(_portfolio.id);
}
/**
* API body
*
* @summary ORG_058 - CRUD (ADMIN) #62
*
* @param {string} id Id
*/
@Put("{id}")
async Put(
@Path() id: string,
@Body()
requestBody: CreatePortfolio,
@Request() request: RequestWithUser,
) {
const _portfolio = await this.portfolioRepository.findOne({ where: { id: id } });
if (!_portfolio) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผลงานนี้");
}
const checkName = await this.portfolioRepository.findOne({
where: { id: Not(id), name: requestBody.name, createdUserId: request.user.sub },
});
if (checkName) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
}
_portfolio.lastUpdateUserId = request.user.sub;
_portfolio.lastUpdateFullName = request.user.name;
_portfolio.lastUpdatedAt = new Date();
Object.assign(_portfolio, requestBody);
// addLogSequence(request, {
// action: "database",
// status: "success",
// description: "Store Portfolio.",
// });
await this.portfolioRepository.save(_portfolio, { data: request });
return new HttpSuccess(_portfolio.id);
}
/**
* API
*
* @summary ORG_058 - CRUD (ADMIN) #62
*
* @param {string} id Id
*/
@Delete("{id}")
async Delete(@Path() id: string, @Request() request: RequestWithUser) {
const _delPortfolio = await this.portfolioRepository.findOne({
where: { id: id, createdUserId: request.user.sub },
});
if (!_delPortfolio) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผลงานนี้");
}
// addLogSequence(request, {
// action: "database",
// status: "success",
// description: "Store Portfolio.",
// });
await this.portfolioRepository.delete(_delPortfolio.id), { data: request };
return new HttpSuccess();
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,743 @@
import {
Body,
Controller,
Delete,
Get,
Patch,
Path,
Post,
Put,
Request,
Route,
Security,
Tags,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import { StrategyChild1 } from "../entities/StrategyChild1";
import { StrategyChild2 } from "../entities/StrategyChild2";
import { StrategyChild3 } from "../entities/StrategyChild3";
import { StrategyChild4 } from "../entities/StrategyChild4";
import { StrategyChild5 } from "../entities/StrategyChild5";
import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status";
import HttpSuccess from "../interfaces/http-success";
import { setLogDataDiff } from "../interfaces/utils";
import { RequestWithUser } from "../middlewares/user";
import permission from "../interfaces/permission";
@Route("api/v1/development/strategy")
@Tags("Strategy")
@Security("bearerAuth")
export class StrategyController extends Controller {
private strategy1Repo = AppDataSource.getRepository(StrategyChild1);
private strategy2Repo = AppDataSource.getRepository(StrategyChild2);
private strategy3Repo = AppDataSource.getRepository(StrategyChild3);
private strategy4Repo = AppDataSource.getRepository(StrategyChild4);
private strategy5Repo = AppDataSource.getRepository(StrategyChild5);
@Get("indicator")
public async listStrategyChild(@Request() request: RequestWithUser) {
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
const listStrategyChild1 = await this.strategy1Repo.find({
relations: [
"strategyChild2s",
"strategyChild2s.strategyChild3s",
"strategyChild2s.strategyChild3s.strategyChild4s",
"strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s",
],
order: {
order: "ASC",
strategyChild2s: {
order: "ASC",
strategyChild3s: {
order: "ASC",
strategyChild4s: { order: "ASC", strategyChild5s: { order: "ASC" } },
},
},
},
});
const formattedData = listStrategyChild1.map((item) => ({
id: item.id,
level: 1,
name: item.strategyChild1Name,
order: item.order,
children: item.strategyChild2s.map((child2) => ({
id: child2.id,
level: 2,
name: child2.strategyChild2Name,
order: child2.order,
children: child2.strategyChild3s
? child2.strategyChild3s.map((child3) => ({
id: child3.id,
level: 3,
name: child3.strategyChild3Name,
order: child3.order,
children: child3.strategyChild4s
? child3.strategyChild4s.map((child4) => ({
id: child4.id,
level: 4,
name: child4.strategyChild4Name,
order: child4.order,
children: child4.strategyChild5s
? child4.strategyChild5s.map((child5) => ({
id: child5.id,
level: 5,
name: child5.strategyChild5Name,
order: child5.order,
}))
: [],
}))
: [],
}))
: [],
})),
}));
return new HttpSuccess(formattedData);
}
@Get("edit/{page}")
public async listStrategyChild1Edit(@Request() request: RequestWithUser, @Path() page: string) {
let _page = page.trim().toUpperCase();
if (_page == "STRATEGIC") {
await new permission().PermissionList(request, "SYS_EVA_STRATIGIC");
} else if (_page == "DEVELOP") {
await new permission().PermissionGet(request, "SYS_DEV_PROJECT");
} else if (_page == "INDICATOR") {
await new permission().PermissionGet(request, "SYS_EVA_INDICATOR");
} else {
await new permission().PermissionList(request, "SYS_EVA_STRATIGIC");
}
const listStrategyChild1 = await this.strategy1Repo.find({
relations: [
"strategyChild2s",
"strategyChild2s.strategyChild3s",
"strategyChild2s.strategyChild3s.strategyChild4s",
"strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s",
],
order: {
order: "ASC",
strategyChild2s: {
order: "ASC",
strategyChild3s: {
order: "ASC",
strategyChild4s: { order: "ASC", strategyChild5s: { order: "ASC" } },
},
},
},
});
// if (!listStrategyChild1 || listStrategyChild1.length === 0) {
// throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
// }
const formattedData = listStrategyChild1.map((item) => ({
id: item.id,
level: 1,
name: item.strategyChild1Name,
order: item.order,
children: item.strategyChild2s.map((child2) => ({
id: child2.id,
level: 2,
name: child2.strategyChild2Name,
order: child2.order,
children: child2.strategyChild3s
? child2.strategyChild3s.map((child3) => ({
id: child3.id,
level: 3,
name: child3.strategyChild3Name,
order: child3.order,
children: child3.strategyChild4s
? child3.strategyChild4s.map((child4) => ({
id: child4.id,
level: 4,
name: child4.strategyChild4Name,
order: child4.order,
children: child4.strategyChild5s
? child4.strategyChild5s.map((child5) => ({
id: child5.id,
level: 5,
name: child5.strategyChild5Name,
order: child5.order,
}))
: [],
}))
: [],
}))
: [],
})),
}));
return new HttpSuccess(formattedData);
}
@Get()
public async listStrategyChild1(@Request() request: RequestWithUser) {
const listStrategyChild1 = await this.strategy1Repo.find({
relations: [
"strategyChild2s",
"strategyChild2s.strategyChild3s",
"strategyChild2s.strategyChild3s.strategyChild4s",
"strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s",
],
order: {
order: "ASC",
strategyChild2s: {
order: "ASC",
strategyChild3s: {
order: "ASC",
strategyChild4s: { order: "ASC", strategyChild5s: { order: "ASC" } },
},
},
},
});
// if (!listStrategyChild1 || listStrategyChild1.length === 0) {
// throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
// }
const formattedData = listStrategyChild1.map((item) => ({
id: item.id,
level: 1,
name: item.strategyChild1Name,
order: item.order,
children: item.strategyChild2s.map((child2) => ({
id: child2.id,
level: 2,
name: child2.strategyChild2Name,
order: child2.order,
children: child2.strategyChild3s
? child2.strategyChild3s.map((child3) => ({
id: child3.id,
level: 3,
name: child3.strategyChild3Name,
order: child3.order,
children: child3.strategyChild4s
? child3.strategyChild4s.map((child4) => ({
id: child4.id,
level: 4,
name: child4.strategyChild4Name,
order: child4.order,
children: child4.strategyChild5s
? child4.strategyChild5s.map((child5) => ({
id: child5.id,
level: 5,
name: child5.strategyChild5Name,
order: child5.order,
}))
: [],
}))
: [],
}))
: [],
})),
}));
return new HttpSuccess(formattedData);
}
@Post()
public async newStrategyChild(
@Request() request: RequestWithUser,
@Body()
body: {
name: string;
levelnode: number;
idnode?: string | null;
},
) {
await new permission().PermissionCreate(request, "SYS_EVA_STRATIGIC");
let strategyRepo: any;
let strategyChild: any;
let repoSave: any;
switch (body.levelnode) {
case 0:
const ckOrder = await this.strategy1Repo.findOne({
where: {},
order: { order: "DESC" },
});
strategyRepo = this.strategy1Repo;
strategyRepo = this.strategy1Repo;
repoSave = this.strategy1Repo;
strategyChild = new StrategyChild1();
strategyChild.strategyChild1Name = body.name;
strategyChild.order = ckOrder ? ckOrder.order + 1 : 1;
break;
case 1:
strategyRepo = this.strategy1Repo;
repoSave = this.strategy2Repo;
strategyChild = new StrategyChild2();
strategyChild.strategyChild2Name = body.name;
strategyChild.order = 1;
if (body.idnode) {
const chk1 = await this.strategy1Repo.findOne({
where: { id: body.idnode },
order: { order: "DESC" },
});
if (chk1) {
strategyChild.strategyChild1Id = chk1.id;
strategyChild.order = chk1 ? chk1.order + 1 : 1;
} else {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
}
}
break;
case 2:
strategyRepo = this.strategy2Repo;
repoSave = this.strategy3Repo;
strategyChild = new StrategyChild3();
strategyChild.strategyChild3Name = body.name;
strategyChild.order = 1;
if (body.idnode) {
const chk2 = await this.strategy2Repo.findOne({
where: { id: body.idnode },
order: { order: "DESC" },
});
if (chk2) {
strategyChild.strategyChild1Id = chk2.strategyChild1Id;
strategyChild.strategyChild2Id = chk2.id;
strategyChild.order = chk2 ? chk2.order + 1 : 1;
} else {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
}
}
break;
case 3:
strategyRepo = this.strategy3Repo;
repoSave = this.strategy4Repo;
strategyChild = new StrategyChild4();
strategyChild.strategyChild4Name = body.name;
strategyChild.order = 1;
if (body.idnode) {
const chk3 = await this.strategy3Repo.findOne({
where: { id: body.idnode },
order: { order: "DESC" },
});
if (chk3) {
strategyChild.strategyChild1Id = chk3.strategyChild1Id;
strategyChild.strategyChild2Id = chk3.strategyChild2Id;
strategyChild.strategyChild3Id = chk3.id;
strategyChild.order = chk3 ? chk3.order + 1 : 1;
} else {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
}
}
break;
case 4:
strategyRepo = this.strategy4Repo;
repoSave = this.strategy5Repo;
strategyChild = new StrategyChild5();
strategyChild.strategyChild5Name = body.name;
strategyChild.order = 1;
if (body.idnode) {
const chk4 = await this.strategy4Repo.findOne({
where: { id: body.idnode },
order: { order: "DESC" },
});
if (chk4) {
strategyChild.strategyChild1Id = chk4.strategyChild1Id;
strategyChild.strategyChild2Id = chk4.strategyChild2Id;
strategyChild.strategyChild3Id = chk4.strategyChild3Id;
strategyChild.strategyChild4Id = chk4.id;
strategyChild.order = chk4 ? chk4.order + 1 : 1;
} else {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
}
}
break;
default:
throw new HttpError(HttpStatus.BAD_REQUEST, "levelnode ไม่ถูกต้อง");
}
const before = null;
strategyChild.createdUserId = request.user.sub;
strategyChild.createdFullName = request.user.name;
strategyChild.lastUpdateUserId = request.user.sub;
strategyChild.lastUpdateFullName = request.user.name;
strategyChild.createdAt = new Date();
strategyChild.lastUpdatedAt = new Date();
// addLogSequence(request, {
// action: "database",
// status: "success",
// description: "Store Strategy.",
// });
await repoSave.save(strategyChild, { data: request });
setLogDataDiff(request, { before, after: strategyChild });
return new HttpSuccess(strategyChild.id);
}
@Patch()
public async editStrategyChild1(
@Request() request: RequestWithUser,
@Body()
body: {
name: string;
levelnode: number;
idnode: string;
},
) {
await new permission().PermissionUpdate(request, "SYS_EVA_STRATIGIC");
let strategyRepo: any;
let strategyChild: any;
switch (body.levelnode) {
case 1:
strategyRepo = this.strategy1Repo;
strategyChild = await strategyRepo.findOne({
where: { id: body.idnode },
});
if (!strategyChild) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
}
strategyChild.strategyChild1Name = body.name;
break;
case 2:
strategyRepo = this.strategy2Repo;
strategyChild = await strategyRepo.findOne({
where: { id: body.idnode },
});
if (!strategyChild) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
}
strategyChild.strategyChild2Name = body.name;
break;
case 3:
strategyRepo = this.strategy3Repo;
strategyChild = await strategyRepo.findOne({
where: { id: body.idnode },
});
if (!strategyChild) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
}
strategyChild.strategyChild3Name = body.name;
break;
case 4:
strategyRepo = this.strategy4Repo;
strategyChild = await strategyRepo.findOne({
where: { id: body.idnode },
});
if (!strategyChild) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
}
strategyChild.strategyChild4Name = body.name;
break;
case 5:
strategyRepo = this.strategy5Repo;
strategyChild = await this.strategy5Repo.findOne({
where: { id: body.idnode },
});
if (!strategyChild) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
}
strategyChild.strategyChild5Name = body.name;
break;
default:
throw new HttpError(HttpStatus.BAD_REQUEST, "levelnode ไม่ถูกต้อง");
}
strategyChild.lastUpdateUserId = request.user.sub;
strategyChild.lastUpdateFullName = request.user.name;
strategyChild.lastUpdatedAt = new Date();
// addLogSequence(request, {
// action: "remove",
// status: "success",
// description: "Edit Strategy by ID.",
// });
await strategyRepo.save(strategyChild, { data: request });
return new HttpSuccess();
}
@Delete()
public async deleteStrategyChild(
@Request() request: RequestWithUser,
@Body()
body: {
levelnode: number;
idnode: string;
},
) {
await new permission().PermissionDelete(request, "SYS_EVA_STRATIGIC");
let strategyRepo: any;
let data: any;
switch (body.levelnode) {
case 1:
strategyRepo = this.strategy1Repo;
data = await strategyRepo.find({
where: { id: body.idnode },
});
if (!data) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
}
await this.strategy5Repo.delete({ strategyChild1Id: body.idnode });
await this.strategy4Repo.delete({ strategyChild1Id: body.idnode });
await this.strategy3Repo.delete({ strategyChild1Id: body.idnode });
await this.strategy2Repo.delete({ strategyChild1Id: body.idnode });
await this.strategy1Repo.delete({ id: body.idnode });
break;
case 2:
strategyRepo = this.strategy2Repo;
data = await strategyRepo.find({
where: { id: body.idnode },
});
if (!data) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
}
await this.strategy5Repo.delete({ strategyChild2Id: body.idnode });
await this.strategy4Repo.delete({ strategyChild2Id: body.idnode });
await this.strategy3Repo.delete({ strategyChild2Id: body.idnode });
await this.strategy2Repo.delete({ id: body.idnode });
break;
case 3:
strategyRepo = this.strategy3Repo;
data = await strategyRepo.find({
where: { id: body.idnode },
});
if (!data) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
}
await this.strategy5Repo.delete({ strategyChild3Id: body.idnode });
await this.strategy4Repo.delete({ strategyChild3Id: body.idnode });
await this.strategy3Repo.delete({ id: body.idnode });
break;
case 4:
strategyRepo = this.strategy4Repo;
data = await strategyRepo.find({
where: { id: body.idnode },
});
if (!data) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
}
await this.strategy5Repo.delete({ strategyChild4Id: body.idnode });
await this.strategy4Repo.delete({ id: body.idnode });
break;
case 5:
strategyRepo = this.strategy5Repo;
data = await strategyRepo.find({
where: { id: body.idnode },
});
if (!data) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
}
await this.strategy5Repo.delete({ id: body.idnode });
break;
default:
throw new HttpError(HttpStatus.BAD_REQUEST, "levelnode ไม่ถูกต้อง");
}
if (!data) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess();
}
/**
* API node detail
*
* @summary node detail (ADMIN)
*
*/
@Post("find/all")
async findNodeAllDetail(@Body() requestBody: { strategy: number; strategyId: string }) {
switch (requestBody.strategy) {
case 1: {
const data = await this.strategy1Repo.findOne({
where: { id: requestBody.strategyId },
});
if (data == null) {
throw new HttpError(HttpStatus.NOT_FOUND, "not found rootId.");
}
return new HttpSuccess({
strategyChild1Id: data.id,
strategyChild1: data.strategyChild1Name,
});
}
case 2: {
const data = await this.strategy2Repo.findOne({
where: { id: requestBody.strategyId },
relations: {
strategyChild1: true,
},
});
if (data == null) {
throw new HttpError(HttpStatus.NOT_FOUND, "not found child1.");
}
return new HttpSuccess({
strategyChild1Id: data.strategyChild1Id,
strategyChild1:
data.strategyChild1 == null ? null : data.strategyChild1.strategyChild1Name,
strategyChild2Id: data.id,
strategyChild2: data.strategyChild2Name,
});
}
case 3: {
const data = await this.strategy3Repo.findOne({
where: { id: requestBody.strategyId },
relations: {
strategyChild1: true,
strategyChild2: true,
},
});
if (data == null) {
throw new HttpError(HttpStatus.NOT_FOUND, "not found child2.");
}
return new HttpSuccess({
strategyChild1Id: data.strategyChild1Id,
strategyChild1:
data.strategyChild1 == null ? null : data.strategyChild1.strategyChild1Name,
strategyChild2Id: data.strategyChild2Id,
strategyChild2:
data.strategyChild2 == null ? null : data.strategyChild2.strategyChild2Name,
strategyChild3Id: data.id,
strategyChild3: data.strategyChild3Name,
});
}
case 4: {
const data = await this.strategy4Repo.findOne({
where: { id: requestBody.strategyId },
relations: {
strategyChild1: true,
strategyChild2: true,
strategyChild3: true,
},
});
if (data == null) {
throw new HttpError(HttpStatus.NOT_FOUND, "not found child3.");
}
return new HttpSuccess({
strategyChild1Id: data.strategyChild1Id,
strategyChild1:
data.strategyChild1 == null ? null : data.strategyChild1.strategyChild1Name,
strategyChild2Id: data.strategyChild2Id,
strategyChild2:
data.strategyChild2 == null ? null : data.strategyChild2.strategyChild2Name,
strategyChild3Id: data.strategyChild3Id,
strategyChild3:
data.strategyChild3 == null ? null : data.strategyChild3.strategyChild3Name,
strategyChild4Id: data.id,
strategyChild4: data.strategyChild4Name,
});
}
case 5: {
const data = await this.strategy5Repo.findOne({
where: { id: requestBody.strategyId },
relations: {
strategyChild1: true,
strategyChild2: true,
strategyChild3: true,
strategyChild4: true,
},
});
if (data == null) {
throw new HttpError(HttpStatus.NOT_FOUND, "not found child4.");
}
return new HttpSuccess({
strategyChild1Id: data.strategyChild1Id,
strategyChild1:
data.strategyChild1 == null ? null : data.strategyChild1.strategyChild1Name,
strategyChild2Id: data.strategyChild2Id,
strategyChild2:
data.strategyChild2 == null ? null : data.strategyChild2.strategyChild2Name,
strategyChild3Id: data.strategyChild3Id,
strategyChild3:
data.strategyChild3 == null ? null : data.strategyChild3.strategyChild3Name,
strategyChild4Id: data.strategyChild4Id,
strategyChild4:
data.strategyChild4 == null ? null : data.strategyChild4.strategyChild4Name,
strategyChild5Id: data.id,
strategyChild5: data.strategyChild5Name,
});
}
default:
throw new HttpError(HttpStatus.NOT_FOUND, "not found type: " + requestBody.strategy);
}
}
/**
* API
*
* @summary (ADMIN)
*
*/
@Post("sort")
async sortNode(
@Body() requestBody: { strategy: number; strategyId: string[]; id: string | null },
@Request() request: RequestWithUser,
) {
switch (requestBody.strategy) {
case 1: {
const data = await this.strategy1Repo.find();
if (data == null) {
throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy1.");
}
const sortLevel = data.map((data) => ({
...data,
order: requestBody.strategyId.indexOf(data.id) + 1,
}));
await this.strategy1Repo.save(sortLevel);
return new HttpSuccess(sortLevel);
}
case 2: {
const data = await this.strategy2Repo.find({
where: { strategyChild1Id: requestBody.id ?? "" },
});
if (data == null) {
throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy2.");
}
const sortLevel = data.map((data) => ({
...data,
order: requestBody.strategyId.indexOf(data.id) + 1,
}));
await this.strategy2Repo.save(sortLevel);
return new HttpSuccess(sortLevel);
}
case 3: {
const data = await this.strategy3Repo.find({
where: { strategyChild2Id: requestBody.id ?? "" },
});
if (data == null) {
throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy3.");
}
const sortLevel = data.map((data) => ({
...data,
order: requestBody.strategyId.indexOf(data.id) + 1,
}));
await this.strategy3Repo.save(sortLevel);
return new HttpSuccess(sortLevel);
}
case 4: {
const data = await this.strategy4Repo.find({
where: { strategyChild3Id: requestBody.id ?? "" },
});
if (data == null) {
throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy4.");
}
const sortLevel = data.map((data) => ({
...data,
order: requestBody.strategyId.indexOf(data.id) + 1,
}));
await this.strategy4Repo.save(sortLevel);
return new HttpSuccess(sortLevel);
}
case 5: {
const data = await this.strategy5Repo.find({
where: { strategyChild4Id: requestBody.id ?? "" },
});
if (data == null) {
throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy5.");
}
const sortLevel = data.map((data) => ({
...data,
order: requestBody.strategyId.indexOf(data.id) + 1,
}));
await this.strategy5Repo.save(sortLevel);
return new HttpSuccess(sortLevel);
}
default:
throw new HttpError(HttpStatus.NOT_FOUND, "not found type: " + requestBody.strategy);
}
}
}

View file

@ -1,6 +1,46 @@
import "dotenv/config";
import "reflect-metadata";
import { DataSource } from "typeorm";
import { DataSource, LogLevel, LogMessage } from "typeorm";
import { Logger } from "typeorm";
import { QueryRunner } from "typeorm/browser";
import { RequestWithUser } from "../middlewares/user";
import { addLogSequence } from "../interfaces/utils";
export class MyCustomLogger implements Logger {
log(level: "log" | "info" | "warn", message: any, queryRunner?: QueryRunner) {}
logQuery(query: string, parameters?: any[], queryRunner?: QueryRunner): void {
const req = queryRunner?.data as RequestWithUser;
if (req?.app?.locals.logData?.sequence) {
addLogSequence(req, {
action: "database",
status: "success",
description: "Query Data.",
query: [
"Query: " + query + (parameters ? " - Parameters:" + JSON.stringify(parameters) : ""),
],
});
}
// const req = queryRunner?.data as RequestWithUser | undefined;
// const logData = req?.app?.locals.logData?.sequence?.at(-1);
// if (logData && !logData.query) logData.query = [];
// if (logData) logData.query.push(
// "Query: " + query + (parameters ? (" - Parameters:" + JSON.stringify(parameters)) : '')
// );
}
logMigration(message: string, queryRunner?: QueryRunner) {}
logQueryError(
error: string | Error,
query: string,
parameters?: any[],
queryRunner?: QueryRunner,
) {}
logQuerySlow(time: number, query: string, parameters?: any[], queryRunner?: QueryRunner) {}
logSchemaBuild(message: string, queryRunner?: QueryRunner) {}
}
export const AppDataSource = new DataSource({
type: "mysql",
@ -11,7 +51,7 @@ export const AppDataSource = new DataSource({
password: process.env.DB_PASSWORD,
connectorPackage: "mysql2",
synchronize: false,
logging: true,
logging: ["query", "error"],
entities:
process.env.NODE_ENV !== "production"
? ["src/entities/**/*.ts"]
@ -21,7 +61,5 @@ export const AppDataSource = new DataSource({
? ["src/migration/**/*.ts"]
: ["dist/migration/**/*{.ts,.js}"],
subscribers: [],
logger: new MyCustomLogger(),
});
// console.log(AppDataSource);
// export default database;

113
src/entities/ActualGoal.ts Normal file
View file

@ -0,0 +1,113 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { Development } from "./Development";
import { PosLevel } from "./PosLevel";
import { PosType } from "./PosType";
@Entity("actualGoal")
export class ActualGoal extends EntityBase {
@Column({
nullable: true,
comment: "กลุ่มเป้าหมาย",
default: null,
})
groupTarget: string;
@Column({
nullable: true,
comment: "กลุ่มเป้าหมายย่อย",
default: null,
})
groupTargetSub: string;
@Column({
nullable: true,
comment: "ตำแหน่ง",
default: null,
})
position: string;
@Column({
nullable: true,
comment: "ประเภทตำแหน่ง & กลุ่มงาน",
default: null,
})
posTypeActual: string;
// @Column({
// nullable: true,
// comment: "ประเภทตำแหน่ง",
// default: null,
// })
// posTypeActualId: string;
// @ManyToOne(() => PosType, (posType: PosType) => posType.actualGoals)
// @JoinColumn({ name: "posTypeActualId" })
// posTypeActual: PosType;
@Column({
nullable: true,
comment: "ระดับตำแหน่ง & ระดับชั้นงาน",
default: null,
})
posLevelActual: string;
// @Column({
// nullable: true,
// comment: "ระดับตำแหน่ง",
// default: null,
// })
// posLevelActualId: string;
// @ManyToOne(() => PosLevel, (posLevel: PosLevel) => posLevel.actualGoals)
// @JoinColumn({ name: "posLevelActualId" })
// posLevelActual: PosLevel;
@Column({
nullable: true,
comment: "ประเภท(กลุ่มอาชีพ คุณสมบัติ)",
default: null,
})
type: string;
@Column({
nullable: true,
comment: "จำนวน(คน)",
default: null,
})
amount: number;
@Column({
nullable: true,
comment: "id โครงการ",
default: null,
})
developmentActualGoalId: string;
@ManyToOne(() => Development, (development: Development) => development.developmentActualGoals)
@JoinColumn({ name: "developmentActualGoalId" })
developmentActualGoal: Development;
}
export class CreateActualGoal {
@Column()
groupTarget: string | null;
@Column()
groupTargetSub: string | null;
@Column()
position: string | null;
// @Column()
// posTypeActualId: string | null;
// @Column()
// posLevelActualId: string | null;
@Column()
posTypeActual: string | null;
@Column()
posLevelActual: string | null;
@Column()
type: string | null;
@Column()
amount: number | null;
}
export type UpdateActualGoal = Partial<CreateActualGoal>;

View file

@ -0,0 +1,40 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { Development } from "./Development";
@Entity("actualPeople")
export class ActualPeople extends EntityBase {
@Column({
nullable: true,
comment: "ผู้เกี่ยวข้อง",
default: null,
})
groupTarget: string;
@Column({
nullable: true,
comment: "จำนวน(คน)",
default: null,
})
amount: number;
@Column({
nullable: true,
comment: "id โครงการ",
default: null,
})
developmentActualPeopleId: string;
@ManyToOne(() => Development, (development: Development) => development.developmentActualPeoples)
@JoinColumn({ name: "developmentActualPeopleId" })
developmentActualPeople: Development;
}
export class CreateActualPeople {
@Column()
groupTarget: string | null;
@Column()
amount: number | null;
}
export type UpdateActualPeople = Partial<CreateActualPeople>;

949
src/entities/Development.ts Normal file
View file

@ -0,0 +1,949 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToMany, Double } from "typeorm";
import { EntityBase } from "./base/Base";
import { ActualPeople, CreateActualPeople } from "./ActualPeople";
import { CreatePlannedPeople, PlannedPeople } from "./PlannedPeople";
import { ActualGoal, CreateActualGoal } from "./ActualGoal";
import { CreatePlannedGoal, PlannedGoal } from "./PlannedGoal";
import { DevelopmentHistory } from "./DevelopmentHistory";
import { DevelopmentProjectType } from "./DevelopmentProjectType";
import { DevelopmentProjectTechniquePlanned } from "./DevelopmentProjectTechniquePlanned";
import { DevelopmentEvaluation } from "./DevelopmentEvaluation";
import { CreateDevelopmentAddress, DevelopmentAddress } from "./DevelopmentAddress";
import { DevelopmentProjectTechniqueActual } from "./DevelopmentProjectTechniqueActual";
import { StrategyChild5 } from "./StrategyChild5";
import { StrategyChild4 } from "./StrategyChild4";
import { StrategyChild3 } from "./StrategyChild3";
import { StrategyChild2 } from "./StrategyChild2";
import { StrategyChild1 } from "./StrategyChild1";
import { DevelopmentRisk } from "./DevelopmentRisk";
import { DevelopmentOther } from "./DevelopmentOther";
@Entity("development")
export class Development extends EntityBase {
@Column({
nullable: true,
comment: "id หน่วยงาน",
default: null,
})
rootId: string;
@Column({
nullable: true,
comment: "id Dna หน่วยงาน",
default: null,
})
rootDnaId: string;
@Column({
nullable: true,
comment: "ชื่อหน่วยงาน",
default: null,
})
root: string;
@Column({
nullable: true,
comment: "ชื่อย่อหน่วยงาน",
default: null,
})
rootShortName: string;
@Column({
nullable: true,
comment: "id หน่วยงาน child1",
default: null,
})
child1Id: string;
@Column({
nullable: true,
comment: "id Dna หน่วยงาน child1",
default: null,
})
child1DnaId: string;
@Column({
nullable: true,
comment: "ชื่อหน่วยงาน child1",
default: null,
})
child1: string;
@Column({
nullable: true,
comment: "ชื่อย่อหน่วยงาน child1",
default: null,
})
child1ShortName: string;
@Column({
nullable: true,
comment: "id หน่วยงาน child2",
default: null,
})
child2Id: string;
@Column({
nullable: true,
comment: "id Dna หน่วยงาน child2",
default: null,
})
child2DnaId: string;
@Column({
nullable: true,
comment: "ชื่อหน่วยงาน child2",
default: null,
})
child2: string;
@Column({
nullable: true,
comment: "ชื่อย่อหน่วยงาน child2",
default: null,
})
child2ShortName: string;
@Column({
nullable: true,
comment: "id หน่วยงาน child3",
default: null,
})
child3Id: string;
@Column({
nullable: true,
comment: "id Dna หน่วยงาน child3",
default: null,
})
child3DnaId: string;
@Column({
nullable: true,
comment: "ชื่อหน่วยงาน child3",
default: null,
})
child3: string;
@Column({
nullable: true,
comment: "ชื่อย่อหน่วยงาน child3",
default: null,
})
child3ShortName: string;
@Column({
nullable: true,
comment: "id หน่วยงาน child4",
default: null,
})
child4Id: string;
@Column({
nullable: true,
comment: "id Dna หน่วยงาน child4",
default: null,
})
child4DnaId: string;
@Column({
nullable: true,
comment: "ชื่อหน่วยงาน child4",
default: null,
})
child4: string;
@Column({
nullable: true,
comment: "ชื่อย่อหน่วยงาน child4",
default: null,
})
child4ShortName: string;
@Column({
nullable: true,
comment: "id revision",
default: null,
})
orgRevisionId: string;
@Column({
// กำลังดำเนินการ (ONGOING)
// เสร็จสิ้น (FINISH)
nullable: true,
comment: "สถานะ",
default: "ONGOING",
})
status: string;
////////////////////////////////////////tab ข้อมูลเบื้องต้น
@Column({
nullable: true,
comment: "ปีงบประมาณ",
})
year: number;
@Column({
comment: "ชื่อโครงการ/กิจกรรม/หลักสูตร",
length: 255,
})
projectName: string;
@Column({
nullable: true,
comment: "หลักการและเหตุผล",
default: null,
type: "text",
})
reason: string;
@Column({
nullable: true,
comment: "วัตถุประสงค์",
default: null,
type: "text",
})
objective: string;
////////////////////////////////////////tab เป้าหมาย
@OneToMany(
() => ActualPeople,
(actualPeople: ActualPeople) => actualPeople.developmentActualPeople,
)
developmentActualPeoples: ActualPeople[];
@OneToMany(() => ActualGoal, (actualGoal: ActualGoal) => actualGoal.developmentActualGoal)
developmentActualGoals: ActualGoal[];
@OneToMany(
() => PlannedPeople,
(plannedPeople: PlannedPeople) => plannedPeople.developmentPlannedPeople,
)
developmentPlannedPeoples: PlannedPeople[];
@OneToMany(() => PlannedGoal, (plannedGoal: PlannedGoal) => plannedGoal.developmentPlannedGoal)
developmentPlannedGoals: PlannedGoal[];
@OneToMany(
() => DevelopmentRisk,
(developmentRisk: DevelopmentRisk) => developmentRisk.development,
)
developmentRisks: DevelopmentRisk[];
@OneToMany(
() => DevelopmentOther,
(developmentOther: DevelopmentOther) => developmentOther.development,
)
developmentOthers: DevelopmentOther[];
@OneToMany(
() => DevelopmentProjectType,
(developmentProjectType: DevelopmentProjectType) => developmentProjectType.development,
)
developmentProjectTypes: DevelopmentProjectType[];
@Column({
comment: "ไป-กลับ",
default: false,
})
isBackPlanned: boolean;
@Column({
comment: "พักค้าง",
default: false,
})
isHoldPlanned: boolean;
@Column({
nullable: true,
comment: "จำนวน(วัน)(ไป-กลับ)",
default: null,
})
projectDayBackPlanned: number;
@Column({
nullable: true,
comment: "จำนวน(วัน)(พักค้าง)",
default: null,
})
projectDayHoldPlanned: number;
@Column({
nullable: true,
comment: "จำนวน(คืน)(พักค้าง)",
default: null,
})
projectNigthHoldPlanned: number;
@Column({
comment: "ไป-กลับ",
default: false,
})
isBackActual: boolean;
@Column({
comment: "พักค้าง",
default: false,
})
isHoldActual: boolean;
@Column({
nullable: true,
comment: "จำนวน(วัน)(ไป-กลับ)",
default: null,
})
projectDayBackActual: number;
@Column({
nullable: true,
comment: "จำนวน(วัน)(พักค้าง)",
default: null,
})
projectDayHoldActual: number;
@Column({
nullable: true,
comment: "จำนวน(คืน)(พักค้าง)",
default: null,
})
projectNigthHoldActual: number;
@Column({
nullable: true,
comment: "รายละเอียดอื่นๆ 70 แผน",
default: null,
})
reasonPlanned70: string;
@Column({
nullable: true,
comment: "รายละเอียดอื่นๆ 20 แผน",
default: null,
})
reasonPlanned20: string;
@Column({
nullable: true,
comment: "รายละเอียดอื่นๆ 10 แผน",
default: null,
})
reasonPlanned10: string;
@Column({
comment: "รายละเอียดอื่นๆ 70 แผน",
default: false,
})
isReasonPlanned70: boolean;
@Column({
comment: "รายละเอียดอื่นๆ 20 แผน",
default: false,
})
isReasonPlanned20: boolean;
@Column({
comment: "รายละเอียดอื่นๆ 10 แผน",
default: false,
})
isReasonPlanned10: boolean;
@OneToMany(
() => DevelopmentProjectTechniquePlanned,
(developmentProjectTechniquePlanned: DevelopmentProjectTechniquePlanned) =>
developmentProjectTechniquePlanned.development,
)
developmentProjectTechniquePlanneds: DevelopmentProjectTechniquePlanned[];
@Column({
nullable: true,
comment: "รายละเอียดอื่นๆ 70 จริง",
default: null,
})
reasonActual70: string;
@Column({
nullable: true,
comment: "รายละเอียดอื่นๆ 20 จริง",
default: null,
})
reasonActual20: string;
@Column({
nullable: true,
comment: "รายละเอียดอื่นๆ 10 จริง",
default: null,
})
reasonActual10: string;
@Column({
comment: "รายละเอียดอื่นๆ 70 จริง",
default: false,
})
isReasonActual70: boolean;
@Column({
comment: "รายละเอียดอื่นๆ 20 จริง",
default: false,
})
isReasonActual20: boolean;
@Column({
comment: "รายละเอียดอื่นๆ 10 จริง",
default: false,
})
isReasonActual10: boolean;
@OneToMany(
() => DevelopmentProjectTechniqueActual,
(developmentProjectTechniqueActual: DevelopmentProjectTechniqueActual) =>
developmentProjectTechniqueActual.development,
)
developmentProjectTechniqueActuals: DevelopmentProjectTechniqueActual[];
@Column({
nullable: true,
comment: "จำนวน(รุ่น)ตามแผน",
default: null,
})
projectModalPlanned: number;
@Column({
nullable: true,
comment: "จำนวน(รุ่น)ตามจริง",
default: null,
})
projectModalActual: number;
////////////////////////////////////////tab ผลประเมิน
@OneToMany(
() => DevelopmentEvaluation,
(developmentEvaluation: DevelopmentEvaluation) => developmentEvaluation.development,
)
developmentEvaluations: DevelopmentEvaluation[];
@Column({
nullable: true,
comment: "ประเภทโครงการ",
default: null,
})
project: string;
@Column({
comment: "ผ่านการพิจาณา ได้รับการจัดสรรงบประมาณตามข้อบัญญัติ",
default: false,
})
isPassAllocate: boolean;
@Column({
comment:
"ผ่านการพิจารณา ไม่ได้รับการจัดสรรงบประมาณตามข้อบัญญัติ แต่ได้รับการจัดสรรเงินนอกงบประมาณ",
default: false,
})
isPassNoAllocate: boolean;
@Column({
comment: "ไม่ผ่านการพิจารณา แต่ได้รับการจัดสรรเงินนอกงบประมาณ",
default: false,
})
isNoPass: boolean;
@Column({
comment: "แต่ได้รับการจัดสรรงบประมาณตามข้อบัญญัติ",
default: false,
})
isBudget: boolean;
@Column({
comment: "แต่ได้รับการจัดสรรเงินนอกงบประมาณ",
default: false,
})
isOutBudget: boolean;
////////////////////////////////////////tab อื่นๆ
@Column({
nullable: true,
type: "datetime",
comment: "วันที่เริ่มต้น",
default: null,
})
dateStart: Date;
@Column({
nullable: true,
type: "datetime",
comment: "วันที่สิ้นสุด",
default: null,
})
dateEnd: Date;
@Column({
nullable: true,
comment: "รวมระยะเวลา (วัน)",
default: null,
})
totalDate: number;
@OneToMany(
() => DevelopmentAddress,
(developmentAddress: DevelopmentAddress) => developmentAddress.development,
)
developmentAddresss: DevelopmentAddress[];
@Column({
nullable: true,
comment: "ประเภทงบประมาณ",
default: null,
})
budget: string;
@Column({
// เงินบำรุง = MAINTENANCE
// เงินกองทุน = FUND
// เงินอุดหนุน = SUBSIDY
nullable: true,
comment: "ประเภทย่อย",
default: null,
})
budgetSub: string;
@Column({
nullable: true,
comment: "จํานวนงบประมาณที่ขอรับการจัดสรรฯ",
default: 0,
type: "double",
})
accept: Double;
@Column({
nullable: true,
comment: "จํานวนงบประมาณที่ได้รับการจัดสรรฯ",
default: 0,
type: "double",
})
receive: Double;
@Column({
nullable: true,
comment: "จํานวนงบประมาณที่ได้รับอนุมัติ",
default: 0,
type: "double",
})
approved: Double;
@Column({
nullable: true,
comment: "จํานวนงบประมาณที่จ่ายจริง",
default: 0,
type: "double",
})
budgetPay: Double;
@Column({
nullable: true,
comment: "ประเด็นความเสี่ยง",
default: null,
})
issues: string;
@Column({
nullable: true,
comment: "โอกาสที่จะเกิด",
default: null,
})
chance: number;
@Column({
nullable: true,
comment: "ผลกระทบจากการเกิด",
default: null,
})
effects: number;
@Column({
nullable: true,
comment: "ระดับความเสี่ยง",
default: null,
})
riskLevel: string;
@Column({
nullable: true,
comment: "เเนวทางการบริหารความเสี่ยง",
default: null,
})
riskManagement: string;
@Column({
nullable: true,
comment: "ประโยชน์ที่คาดว่าจะได้รับ",
default: null,
})
expect: string;
@Column({
nullable: true,
comment: "หัวข้อ/ประเด็นการฝึกอบรม ศึกษาดูงาน",
default: null,
})
topicAcademic: string;
@Column({
nullable: true,
comment: "สถานที่ฝึกอบรม ศึกษาดูงาน",
default: null,
})
addressAcademic: string;
@Column({
nullable: true,
comment: "จังหวัด(ข้อมูลวิชาการ)",
default: null,
})
provinceActualId: string;
@Column({
nullable: true,
type: "datetime",
comment: "วันเริ่มต้นการศึกษาดูงาน",
default: null,
})
dateStudyStart: Date;
@Column({
nullable: true,
type: "datetime",
comment: "วันสิ้นสุดการศึกษาดูงาน",
default: null,
})
dateStudyEnd: Date;
@OneToMany(
() => DevelopmentHistory,
(developmentHistory: DevelopmentHistory) => developmentHistory.development,
)
developmentHistorys: DevelopmentHistory[];
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild1 เป้าหมายตามแผน",
default: null,
})
strategyChild1PlannedId: string;
@ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.developmentPlanneds)
@JoinColumn({ name: "strategyChild1PlannedId" })
strategyChild1Planned: StrategyChild1;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild2 เป้าหมายตามแผน",
default: null,
})
strategyChild2PlannedId: string;
@ManyToOne(() => StrategyChild2, (strategyChild2) => strategyChild2.developmentPlanneds)
@JoinColumn({ name: "strategyChild2PlannedId" })
strategyChild2Planned: StrategyChild2;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild3 เป้าหมายตามแผน",
default: null,
})
strategyChild3PlannedId: string;
@ManyToOne(() => StrategyChild3, (strategyChild3) => strategyChild3.developmentPlanneds)
@JoinColumn({ name: "strategyChild3PlannedId" })
strategyChild3Planned: StrategyChild3;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild4 เป้าหมายตามแผน",
default: null,
})
strategyChild4PlannedId: string;
@ManyToOne(() => StrategyChild4, (strategyChild4) => strategyChild4.developmentPlanneds)
@JoinColumn({ name: "strategyChild4PlannedId" })
strategyChild4Planned: StrategyChild4;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild5 เป้าหมายตามแผน",
default: null,
})
strategyChild5PlannedId: string;
@ManyToOne(() => StrategyChild5, (strategyChild5) => strategyChild5.developmentPlanneds)
@JoinColumn({ name: "strategyChild5PlannedId" })
strategyChild5Planned: StrategyChild5;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild1 เป้าหมายตามจริง",
default: null,
})
strategyChild1ActualId: string;
@ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.developmentActuals)
@JoinColumn({ name: "strategyChild1ActualId" })
strategyChild1Actual: StrategyChild1;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild2 เป้าหมายตามจริง",
default: null,
})
strategyChild2ActualId: string;
@ManyToOne(() => StrategyChild2, (strategyChild2) => strategyChild2.developmentActuals)
@JoinColumn({ name: "strategyChild2ActualId" })
strategyChild2Actual: StrategyChild2;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild3 เป้าหมายตามจริง",
default: null,
})
strategyChild3ActualId: string;
@ManyToOne(() => StrategyChild3, (strategyChild3) => strategyChild3.developmentActuals)
@JoinColumn({ name: "strategyChild3ActualId" })
strategyChild3Actual: StrategyChild3;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild4 เป้าหมายตามจริง",
default: null,
})
strategyChild4ActualId: string;
@ManyToOne(() => StrategyChild4, (strategyChild4) => strategyChild4.developmentActuals)
@JoinColumn({ name: "strategyChild4ActualId" })
strategyChild4Actual: StrategyChild4;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild5 เป้าหมายตามจริง",
default: null,
})
strategyChild5ActualId: string;
@ManyToOne(() => StrategyChild5, (strategyChild5) => strategyChild5.developmentActuals)
@JoinColumn({ name: "strategyChild5ActualId" })
strategyChild5Actual: StrategyChild5;
@Column({
type: "longtext",
nullable: true,
comment: "การติดตามความก้าวหน้า",
default: null,
})
progressTracking: string;
@Column({
type: "longtext",
nullable: true,
comment: "การประเมินผลโครงการ",
default: null,
})
projectEvaluation: string;
@Column({
type: "longtext",
nullable: true,
comment: "ปัญหาอุปสรรค",
default: null,
})
obstacle: string;
@Column({
type: "longtext",
nullable: true,
comment: "ข้อเสนอแนะ",
default: null,
})
suggestion: string;
}
export class CreateDevelopment {
@Column()
year: number;
@Column()
projectName: string;
@Column()
node: number;
@Column()
nodeId: string;
@Column()
orgRevisionId: string;
}
export class UpdateDevelopment1 {
@Column()
year: number;
@Column()
projectName: string;
@Column()
reason: string | null;
@Column()
objective: string | null;
@Column()
node: number;
@Column()
nodeId: string;
@Column()
orgRevisionId: string;
}
export class UpdateDevelopment2_1 {
@Column()
actualGoals: CreateActualGoal[];
@Column()
plannedGoals: CreatePlannedGoal[];
}
export class UpdateDevelopment2_2 {
@Column()
actualPeoples: CreateActualPeople[];
@Column()
plannedPeoples: CreatePlannedPeople[];
}
export class UpdateDevelopment3 {
//move from tab5
@Column()
dateStart: Date | null;
@Column()
dateEnd: Date | null;
@Column()
totalDate: number | null;
@Column()
developmentAddresss: CreateDevelopmentAddress[];
//end
@Column()
developmentProjectTypes?: string[];
@Column()
projectModalActual?: number | null;
@Column()
projectModalPlanned?: number | null;
@Column()
isBackPlanned?: boolean | null;
@Column()
isHoldPlanned?: boolean | null;
@Column()
projectDayBackPlanned?: number | null;
@Column()
projectDayHoldPlanned?: number | null;
@Column()
projectNigthHoldPlanned?: number | null;
@Column()
developmentProjectTechniquePlanneds?: string[];
@Column()
reasonPlanned70?: string;
@Column()
reasonPlanned20?: string;
@Column()
reasonPlanned10?: string;
@Column()
isReasonPlanned70?: string;
@Column()
isReasonPlanned20?: string;
@Column()
isReasonPlanned10?: string;
@Column()
isBackActual?: boolean | null;
@Column()
isHoldActual?: boolean | null;
@Column()
projectDayBackActual?: number | null;
@Column()
projectDayHoldActual?: number | null;
@Column()
projectNigthHoldActual?: number | null;
@Column()
developmentProjectTechniqueActuals?: string[];
@Column()
reasonActual70?: string;
@Column()
reasonActual20?: string;
@Column()
reasonActual10?: string;
@Column()
isReasonActual70?: boolean;
@Column()
isReasonActual20?: boolean;
@Column()
isReasonActual10?: boolean;
@Column()
strategyChildPlannedId?: string | null;
@Column()
strategyChildPlannedNode?: number | null;
@Column()
strategyChildActualId?: string | null;
@Column()
strategyChildActualNode?: number | null;
}
export class UpdateDevelopment4 {
// @Column()
// developmentEvaluations: CreateDevelopmentEvaluation[];
//new
@Column()
progressTracking: string | null;
@Column()
projectEvaluation: string | null;
//end
}
export class UpdateDevelopment5 {
//new
@Column()
obstacle: string | null;
@Column()
suggestion: string | null;
//end
//move from tab4
@Column()
project: string | null;
@Column()
isPassAllocate: boolean;
@Column()
isPassNoAllocate: boolean;
@Column()
isNoPass: boolean;
@Column()
isBudget: boolean;
@Column()
isOutBudget: boolean;
//end
}
export class UpdateDevelopment7 {
//move from tab5
@Column()
budget: string | null;
@Column()
budgetSub: string | null;
@Column()
budgetPay: Double | null;
@Column()
accept: Double | null;
@Column()
receive: Double | null;
@Column()
approved: Double | null;
//end
}
export class UpdateDevelopment8_1 {
//move from tab5
@Column()
issues: string | null;
@Column()
chance: number | null;
@Column()
effects: number | null;
@Column()
riskLevel: string | null;
@Column()
riskManagement: string | null;
//end
}
export class UpdateDevelopment8 {
@Column()
expect: string | null;
}

View file

@ -0,0 +1,68 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { Development } from "./Development";
@Entity("developmentAddress")
export class DevelopmentAddress extends EntityBase {
@Column({
nullable: true,
comment: "ที่อยู่",
default: null,
})
address: string;
@Column({
nullable: true,
comment: "โครงการ/หลักสูตรการฝึกอบรม",
default: null,
})
provinceId: string;
@Column({
nullable: true,
comment: "ชื่อจังหวัด (กรณีเลือกสถานที่ดำเนินการในประเทศ)",
default: null,
})
provinceName: string;
@Column({
nullable: true,
comment: "โครงการ/หลักสูตรการฝึกอบรม",
default: null,
})
developmentId: string;
@Column({
nullable: true,
comment: "สถานที่ดำเนินการ ในประเทศ(IN_COUNTRY) หรือ ต่างประเทศ(ABROAD)",
default: null,
})
addressType: string;
@Column({
nullable: true,
comment: "ชื่อประเทศ (กรณีเลือกสถานที่ดำเนินการต่างประเทศ)",
default: null,
})
country: string;
@ManyToOne(() => Development, (development: Development) => development.developmentAddresss)
@JoinColumn({ name: "developmentId" })
development: Development;
}
export class CreateDevelopmentAddress {
@Column()
address: string | null;
@Column()
provinceId: string | null;
@Column()
addressType?: string | null;
@Column()
provinceName?: string | null;
@Column()
country?: string | null;
}

View file

@ -0,0 +1,90 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { Development } from "./Development";
@Entity("developmentEvaluation")
export class DevelopmentEvaluation extends EntityBase {
@Column({
nullable: true,
comment: "ตัวชี้วัด",
default: null,
})
indicators: string;
@Column({
nullable: true,
comment: "เป้าหมาย",
default: null,
})
target: number;
@Column({
nullable: true,
comment: "ประเภทตัวชี้วัด",
default: null,
})
metricType: string;
@Column({
nullable: true,
comment: "วิธีการคำนวณ/เครื่องมือ",
default: null,
})
calculation: string;
@Column({
nullable: true,
comment: "ระยะเวลาวัดผล",
default: null,
})
measuRement: string;
@Column({
nullable: true,
comment: "ผลการดำเนิน",
default: null,
})
results: string;
@Column({
nullable: true,
comment: "ปัญหาอุปสรรค",
default: null,
})
obstacles: string;
@Column({
nullable: true,
comment: "ข้อเสนอเเนะ",
default: null,
})
suggestions: string;
@Column({
nullable: true,
comment: "โครงการ/หลักสูตรการฝึกอบรม",
default: null,
})
developmentId: string;
@ManyToOne(() => Development, (development: Development) => development.developmentEvaluations)
@JoinColumn({ name: "developmentId" })
development: Development;
}
export class CreateDevelopmentEvaluation {
@Column()
indicators: string | null;
@Column()
target: number | null;
@Column()
metricType: string | null;
@Column()
calculation: string | null;
@Column()
measuRement: string | null;
@Column()
results?: string | null;
@Column()
obstacles: string | null;
@Column()
suggestions: string | null;
}

View file

@ -0,0 +1,328 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { PosLevel } from "./PosLevel";
import { PosType } from "./PosType";
import { Development } from "./Development";
import { EmployeePosType } from "./EmployeePosType";
import { EmployeePosLevel } from "./EmployeePosLevel";
@Entity("developmentHistory")
export class DevelopmentHistory extends EntityBase {
@Column({
nullable: true,
comment: "id หน่วยงาน",
default: null,
})
rootId: string;
@Column({
nullable: true,
comment: "ชื่อหน่วยงาน",
default: null,
})
root: string;
@Column({
nullable: true,
comment: "ชื่อหน่วยงานที่สังกัด",
default: null,
})
org: string;
@Column({
nullable: true,
comment: "ชื่อย่อหน่วยงาน",
default: null,
})
orgRootShortName: string;
@Column({
nullable: true,
comment: "id revision",
default: null,
})
orgRevisionId: string;
@Column({
nullable: true,
comment: "id profile",
length: 40,
default: null,
})
profileId: string;
@Column({
nullable: true,
comment: "ประเภทราชการ",
length: 40,
default: null,
})
type: string;
@Column({
nullable: true,
comment: "ยศ",
length: 40,
default: null,
})
rank: string;
@Column({
nullable: true,
comment: "คำนำหน้าชื่อ",
length: 40,
default: null,
})
prefix: string;
@Column({
nullable: true,
comment: "ชื่อ",
length: 255,
default: null,
})
firstName: string;
@Column({
nullable: true,
comment: "นามสกุล",
length: 255,
default: null,
})
lastName: string;
@Column({
nullable: true,
comment: "เลขประจำตัวประชาชน",
default: null,
length: 13,
})
citizenId: string;
@Column({
nullable: true,
comment: "ตำแหน่ง",
default: null,
length: 255,
})
position: string;
@Column({
nullable: true,
comment: "ชื่อตำแหน่งทางการบริหาร",
length: 255,
default: null,
})
posExecutive: string;
@Column({
nullable: true,
length: 40,
comment: "ไอดีระดับตำแหน่ง",
})
posLevelId: string | null;
@ManyToOne(() => PosLevel, (posLevel) => posLevel.developmentHistorys)
@JoinColumn({ name: "posLevelId" })
posLevel: PosLevel;
@Column({
nullable: true,
length: 40,
comment: "ไอดีประเภทตำแหน่ง",
})
posTypeId: string | null;
@ManyToOne(() => PosType, (posType) => posType.developmentHistorys)
@JoinColumn({ name: "posTypeId" })
posType: PosType;
@Column({
nullable: true,
length: 40,
comment: "ไอดีระดับตำแหน่ง",
})
employeePosLevelId: string | null;
@ManyToOne(() => EmployeePosLevel, (employeePosLevel) => employeePosLevel.developmentHistorys)
@JoinColumn({ name: "employeePosLevelId" })
employeePosLevel: EmployeePosLevel;
@Column({
nullable: true,
length: 40,
comment: "ไอดีประเภทตำแหน่ง",
})
employeePosTypeId: string | null;
@ManyToOne(() => EmployeePosType, (employeePosType) => employeePosType.developmentHistorys)
@JoinColumn({ name: "employeePosTypeId" })
employeePosType: EmployeePosType;
@Column({
nullable: true,
comment: "โครงการ/หลักสูตรการฝึกอบรม",
default: null,
})
developmentId: string;
@ManyToOne(() => Development, (development: Development) => development.developmentHistorys)
@JoinColumn({ name: "developmentId" })
development: Development;
@Column({
nullable: true,
comment: "จำนวนวันที่อบรม",
default: null,
length: 255,
})
trainingDays: string;
@Column({
nullable: true,
comment: "เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ",
default: null,
length: 255,
})
order: string;
@Column({
nullable: true,
type: "datetime",
comment: "วันที่เริ่มต้น",
default: null,
})
dateStart: Date;
@Column({
nullable: true,
type: "datetime",
comment: "วันที่สิ้นสุด",
default: null,
})
dateEnd: Date;
@Column({
nullable: true,
type: "datetime",
comment: "คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่",
default: null,
})
dateOrder: Date;
@Column({
comment: "บันทึกลงทะเบียนประวัติ",
default: false,
})
isDone: boolean;
@Column({
comment: "บันทึก IDP ที่ทะเบียนประวัติ",
default: false,
})
isDoneIDP: boolean;
@Column({
comment: "มีข้อมูลอยู่ในทะเบียนประวัติ",
default: false,
})
isProfile: boolean;
}
export class CreateDevelopmentHistory {
@Column()
rank: string | null;
@Column()
prefix: string | null;
@Column()
firstName: string | null;
@Column()
lastName: string | null;
@Column()
citizenId: string;
@Column()
position: string | null;
@Column()
posExecutive: string | null;
@Column()
posLevelId: string | null;
@Column()
posTypeId: string | null;
@Column()
developmentId: string;
@Column()
order: string | null;
@Column()
dateOrder: Date | null;
@Column()
dateStart: Date | null;
@Column()
dateEnd: Date | null;
}
export class UpdateDevelopmentHistory {
@Column()
rank: string | null;
@Column()
prefix: string | null;
@Column()
firstName: string | null;
@Column()
lastName: string | null;
@Column()
citizenId: string;
@Column()
position: string | null;
@Column()
posExecutive: string | null;
@Column()
posLevelId: string | null;
@Column()
posTypeId: string | null;
@Column()
developmentId: string;
@Column()
order: string | null;
@Column()
dateOrder: Date | null;
@Column()
dateStart: Date | null;
@Column()
dateEnd: Date | null;
}
export class CreateDevelopmentHistoryOBO {
// @Column()
// rank: string | null;
@Column()
prefix: string | null;
@Column()
firstName: string | null;
@Column()
lastName: string | null;
@Column()
citizenId: string;
@Column()
position: string | null;
@Column()
posExecutive?: string | null;
@Column()
posLevelId?: string | null;
@Column()
posTypeId?: string | null;
// @Column()
// developmentId: string;
@Column()
commandNumber: string | null;
@Column()
commandDate: Date | null;
@Column()
trainingDays: string | null;
@Column()
org: string | null;
@Column()
type: string | null;
@Column()
dateStart: Date | null;
@Column()
dateEnd: Date | null;
}

View file

@ -0,0 +1,54 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { Development } from "./Development";
@Entity("developmentOther")
export class DevelopmentOther extends EntityBase {
@Column({
nullable: true,
comment: "หัวข้อ/ประเด็นการฝึกอบรม ศึกษาดูงาน",
default: null,
})
topicAcademic: string;
@Column({
nullable: true,
comment: "สถานที่ฝึกอบรม ศึกษาดูงาน",
default: null,
})
addressAcademic: string;
@Column({
nullable: true,
comment: "จังหวัด(ข้อมูลวิชาการ)",
default: null,
})
provinceActualId: string;
@Column({
nullable: true,
comment: "จังหวัด(ข้อมูลวิชาการ)",
default: null,
})
provinceActualName: string;
@Column({
nullable: true,
comment: "คีย์นอก(FK)ของตาราง development",
default: null,
})
developmentId: string;
@ManyToOne(() => Development, (development: Development) => development.developmentOthers)
@JoinColumn({ name: "developmentId" })
development: Development;
}
export class UpdateDevelopmentOther {
@Column()
topicAcademic: string | null;
@Column()
addressAcademic: string | null;
@Column()
provinceActualId: string | null;
}

View file

@ -0,0 +1,41 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { Development } from "./Development";
@Entity("developmentProjectTechniqueActual")
export class DevelopmentProjectTechniqueActual extends EntityBase {
@Column({
// TRAINING = การอบรม
// MEETING = การประชุม
// SEMINAR = การสัมมนา
// STUDY_TOUR = การศึกษาดูงาน
// ACADEMIC_SEMINAR = การสัมมนาทางวิชาการ
// WORKSHOP = การสัมมนาเชิงปฏิบัติการ
// SPECIAL_LECTURE = การบรรยายพิเศษ
// LECTURE = การบรรยาย
// STUDY_TRAINING = การฝึกศึกษา
// OTHER = อื่น
nullable: true,
comment: "เทคนิควิธีการที่ใช้ในการพัฒนา",
default: null,
})
name: string;
@Column({
nullable: true,
comment: "โครงการ/หลักสูตรการฝึกอบรม",
default: null,
})
developmentId: string;
@ManyToOne(
() => Development,
(development: Development) => development.developmentProjectTechniqueActuals,
)
@JoinColumn({ name: "developmentId" })
development: Development;
}
export class CreateDevelopmentProjectTechniqueActual {
@Column()
name: string;
}

View file

@ -0,0 +1,41 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { Development } from "./Development";
@Entity("developmentProjectTechniquePlanned")
export class DevelopmentProjectTechniquePlanned extends EntityBase {
@Column({
// TRAINING = การอบรม
// MEETING = การประชุม
// SEMINAR = การสัมมนา
// STUDY_TOUR = การศึกษาดูงาน
// ACADEMIC_SEMINAR = การสัมมนาทางวิชาการ
// WORKSHOP = การสัมมนาเชิงปฏิบัติการ
// SPECIAL_LECTURE = การบรรยายพิเศษ
// LECTURE = การบรรยาย
// STUDY_TRAINING = การฝึกศึกษา
// OTHER = อื่น
nullable: true,
comment: "เทคนิควิธีการที่ใช้ในการพัฒนา",
default: null,
})
name: string;
@Column({
nullable: true,
comment: "โครงการ/หลักสูตรการฝึกอบรม",
default: null,
})
developmentId: string;
@ManyToOne(
() => Development,
(development: Development) => development.developmentProjectTechniquePlanneds,
)
@JoinColumn({ name: "developmentId" })
development: Development;
}
export class CreateDevelopmentProjectTechniquePlanned {
@Column()
name: string;
}

View file

@ -0,0 +1,32 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { Development } from "./Development";
@Entity("developmentProjectType")
export class DevelopmentProjectType extends EntityBase {
@Column({
// STRATEGIC_PROJECT = โครงการตามยุทธศาสตร์
// MISSION_PROJECT = โครงการตามภารกิจประจำของหน่วยงาน
// NEW_PROJECT = โครงการใหม่
// ONGOING_PROJECT = โครงการต่อเนื่อง
nullable: true,
comment: "ประเภทโครงการ",
default: null,
})
name: string;
@Column({
nullable: true,
comment: "โครงการ/หลักสูตรการฝึกอบรม",
default: null,
})
developmentId: string;
@ManyToOne(() => Development, (development: Development) => development.developmentProjectTypes)
@JoinColumn({ name: "developmentId" })
development: Development;
}
export class CreateDevelopmentProjectType {
@Column()
name: string;
}

View file

@ -0,0 +1,65 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { Development } from "./Development";
@Entity("developmentRisk")
export class DevelopmentRisk extends EntityBase {
@Column({
nullable: true,
comment: "ประเด็นความเสี่ยง",
default: null,
})
issues: string;
@Column({
nullable: true,
comment: "โอกาสที่จะเกิด",
default: null,
})
chance: number;
@Column({
nullable: true,
comment: "ผลกระทบจากการเกิด",
default: null,
})
effects: number;
@Column({
nullable: true,
comment: "ระดับความเสี่ยง",
default: null,
})
riskLevel: string;
@Column({
nullable: true,
comment: "เเนวทางการบริหารความเสี่ยง",
default: null,
})
riskManagement: string;
@Column({
nullable: true,
comment: "คีย์นอก(FK)ของตาราง development",
default: null,
})
developmentId: string;
@ManyToOne(() => Development, (development: Development) => development.developmentRisks)
@JoinColumn({ name: "developmentId" })
development: Development;
}
export class UpdateDevelopmentRisk {
@Column()
issues: string | null;
@Column()
chance: number | null;
@Column()
effects: number | null;
@Column()
riskLevel: string | null;
@Column()
riskManagement: string | null;
}

View file

@ -0,0 +1,737 @@
import { Entity, Column, ManyToOne, JoinColumn, Double } from "typeorm";
import { EntityBase } from "./base/Base";
import { PosLevel } from "./PosLevel";
import { PosType } from "./PosType";
@Entity("developmentScholarship")
export class DevelopmentScholarship extends EntityBase {
@Column({
nullable: true,
comment: "id dna หน่วยงาน",
default: null,
})
rootDnaId: string;
@Column({
nullable: true,
comment: "id หน่วยงาน",
default: null,
})
rootId: string;
@Column({
nullable: true,
comment: "ชื่อหน่วยงาน",
default: null,
})
root: string;
@Column({
nullable: true,
comment: "ชื่อหน่วยงานที่สังกัด",
default: null,
})
org: string;
@Column({
nullable: true,
comment: "ชื่อย่อหน่วยงาน",
default: null,
})
orgRootShortName: string;
@Column({
nullable: true,
comment: "id revision",
default: null,
})
orgRevisionId: string;
@Column({
nullable: true,
comment: "id profile",
length: 40,
default: null,
})
profileId: string;
@Column({
// PENDING = ค่าเริ่มต้น
// GRADUATE = สำเร็จการศึกษา
// NOTGRADUATE = ไม่จบการศึกษา
nullable: true,
comment: "สถานะ",
length: 40,
default: "PENDING",
})
status: string;
@Column({
nullable: true,
comment: "ยศ",
length: 40,
default: null,
})
rank: string;
@Column({
nullable: true,
comment: "คำนำหน้าชื่อ",
length: 40,
default: null,
})
prefix: string;
@Column({
nullable: true,
comment: "ชื่อ",
length: 255,
default: null,
})
firstName: string;
@Column({
nullable: true,
comment: "นามสกุล",
length: 255,
default: null,
})
lastName: string;
@Column({
nullable: true,
comment: "เลขประจำตัวประชาชน",
default: null,
length: 13,
})
citizenId: string;
@Column({
nullable: true,
comment: "ตำแหน่ง",
default: null,
length: 255,
})
position: string;
@Column({
nullable: true,
comment: "ชื่อตำแหน่งทางการบริหาร",
length: 255,
default: null,
})
posExecutive: string;
@Column({
nullable: true,
length: 40,
comment: "ไอดีระดับตำแหน่ง",
})
posLevelId: string | null;
@ManyToOne(() => PosLevel, (posLevel) => posLevel.developmentScholars)
@JoinColumn({ name: "posLevelId" })
posLevel: PosLevel;
@Column({
nullable: true,
length: 40,
comment: "ไอดีประเภทตำแหน่ง",
})
posTypeId: string | null;
@ManyToOne(() => PosType, (posType) => posType.developmentScholars)
@JoinColumn({ name: "posTypeId" })
posType: PosType;
@Column({
nullable: true,
comment: "id Dna หน่วยงาน",
default: null,
})
guarantorRootDnaId: string;
@Column({
nullable: true,
comment: "id หน่วยงาน",
default: null,
})
guarantorRootId: string;
@Column({
nullable: true,
comment: "ชื่อหน่วยงาน",
default: null,
})
guarantorRoot: string;
@Column({
nullable: true,
comment: "ชื่อหน่วยงานที่สังกัด",
default: null,
})
guarantorOrg: string;
@Column({
nullable: true,
comment: "ชื่อย่อหน่วยงาน",
default: null,
})
guarantorOrgRootShortName: string;
@Column({
nullable: true,
comment: "id revision",
default: null,
})
guarantorOrgRevisionId: string;
@Column({
nullable: true,
comment: "ยศ(ผู้ค้ำ)",
length: 40,
default: null,
})
guarantorRank: string;
@Column({
nullable: true,
comment: "คำนำหน้าชื่อ(ผู้ค้ำ)",
length: 40,
default: null,
})
guarantorPrefix: string;
@Column({
nullable: true,
comment: "ชื่อ(ผู้ค้ำ)",
length: 255,
default: null,
})
guarantorFirstName: string;
@Column({
nullable: true,
comment: "นามสกุล(ผู้ค้ำ)",
length: 255,
default: null,
})
guarantorLastName: string;
@Column({
nullable: true,
comment: "เลขประจำตัวประชาชน(ผู้ค้ำ)",
default: null,
length: 13,
})
guarantorCitizenId: string;
@Column({
nullable: true,
comment: "ตำแหน่ง(ผู้ค้ำ)",
default: null,
length: 255,
})
guarantorPosition: string;
@Column({
nullable: true,
comment: "ชื่อตำแหน่งทางการบริหาร(ผู้ค้ำ)",
length: 255,
default: null,
})
guarantorPosExecutive: string;
@Column({
nullable: true,
length: 40,
comment: "ไอดีระดับตำแหน่ง(ผู้ค้ำ)",
})
posLevelguarantorId: string | null;
@ManyToOne(() => PosLevel, (posLevel) => posLevel.developmentScholarGuarantors)
@JoinColumn({ name: "posLevelguarantorId" })
posLevelguarantor: PosLevel;
@Column({
nullable: true,
length: 40,
comment: "ไอดีประเภทตำแหน่ง(ผู้ค้ำ)",
})
posTypeguarantorId: string | null;
@ManyToOne(() => PosType, (posType) => posType.developmentScholarGuarantors)
@JoinColumn({ name: "posTypeguarantorId" })
posTypeguarantor: PosType;
@Column({
nullable: true,
comment: "ปีงบประมาณที่ได้รับทุน",
})
scholarshipYear: number;
@Column({
//แหล่งงบประมาณกทม = BKK , แหล่งงบประมาณอื่นๆ = OTHER
nullable: true,
comment: "แหล่งงบประมาณ",
length: 10,
default: null,
})
budgetSource: string;
@Column({
comment: "งบประมาณที่ได้รับอนุมัติตลอดหลักสูตร",
default: 0,
nullable: true,
type: "double",
})
budgetApprove: Double;
@Column({
nullable: true,
comment: "เลขที่หนังสืออนุมัติ",
length: 40,
default: null,
})
bookNo: string;
@Column({
nullable: true,
type: "datetime",
comment: "ลงวันที่(หนังสือ)",
default: null,
})
bookNoDate: Date;
@Column({
nullable: true,
type: "datetime",
comment: "หนังสืออนุมัติเมื่อวันที่",
default: null,
})
bookApproveDate: Date;
@Column({
comment: "ใช้เวลาราชการ",
default: false,
})
useOfficialTime: string;
@Column({
nullable: true,
comment: "เปลี่ยนแปลงรายละเอียด",
type: "text",
default: null,
})
changeDetail: string;
@Column({
//การศึกษาในประเทศ = DOMESTICE
//ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่ไม่มีการไปต่างประเทศ) = NOABROAD
//ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่มีการไปต่างประเทศ) = ABROAD
//ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรประเภทนักบริหาร) = EXECUTIVE
nullable: true,
comment: "เลือกประเภททุน",
length: 40,
default: null,
})
scholarshipType: string;
@Column({
//ทุน 1 (ก)(ข)(ค) = FUND1 , ทุน 2 (ก)(ข) = FUND2
nullable: true,
comment: "ประเภททุน",
length: 40,
default: null,
})
fundType: string;
@Column({
nullable: true,
comment: "เลขที่สัญญา",
length: 40,
default: null,
})
contractNo: string;
@Column({
nullable: true,
type: "datetime",
comment: "ลงวันที่(เลขที่สัญญา)",
default: null,
})
contractDate: Date;
@Column({
nullable: true,
comment: "เลขที่หนังสือรายงานตัวกลับ",
length: 40,
default: null,
})
reportBackNo: string;
@Column({
nullable: true,
type: "datetime",
comment: "ลงวันที่(เลขที่หนังสือรายงานตัวกลับ)",
default: null,
})
reportBackNoDate: Date;
@Column({
nullable: true,
type: "datetime",
comment: "รายงานตัวกลับวันที่",
default: null,
})
reportBackDate: Date;
@Column({
nullable: true,
comment: "ระดับปริญญา",
length: 255,
default: null,
})
degreeLevel: string;
@Column({
nullable: true,
comment: "หลักสูตรการศึกษา/หลักสูตรการฝึกอบรม",
length: 255,
default: null,
})
course: string;
@Column({
nullable: true,
comment: "สาขาวิชา/สาขา",
length: 255,
default: null,
})
field: string;
@Column({
nullable: true,
comment: "คณะ",
length: 255,
default: null,
})
faculty: string;
@Column({
nullable: true,
comment: "สถาบันการศึกษา/สถาบันการศึกษา_หน่วยงานผู้จัดการฝึกอบรม/สถานที่ไปศึกษาดูงานในประเทศ",
length: 255,
default: null,
})
educationalInstitution: string;
@Column({
nullable: true,
type: "datetime",
comment: "วันเริ่มต้นการศึกษา/วันเริ่มต้นการฝึกอบรม/วันเริ่มต้นการศึกษาดูงานในประเทศ",
default: null,
})
startDate: Date;
@Column({
nullable: true,
type: "datetime",
comment: "วันสิ้นสุดการศึกษา/วันสิ้นสุดการฝึกอบรม/วันสิ้นสุดการศึกษาดูงานในประเทศ",
default: null,
})
endDate: Date;
@Column({
nullable: true,
comment: "สถานที่ไปศึกษาดูงาน",
length: 255,
default: null,
})
studyPlace: string;
@Column({
nullable: true,
comment: "หัวข้อการไปศึกษาดูงาน/หัวข้อการไปศึกษาดูงานในประเทศ",
length: 255,
default: null,
})
studyTopic: string;
@Column({
nullable: true,
type: "datetime",
comment: "วันเริ่มต้นการศึกษาดูงาน",
default: null,
})
studyStartDate: Date;
@Column({
nullable: true,
type: "datetime",
comment: "วันสิ้นสุดการศึกษาดูงาน",
default: null,
})
studyEndDate: Date;
@Column({
nullable: true,
comment: "ประเทศที่เดินทางไปศึกษาดูงาน",
length: 255,
default: null,
})
studyCountry: string;
@Column({
nullable: true,
comment: "หัวข้อการไปศึกษาดูงานต่างประเทศ",
length: 255,
default: null,
})
studyAbroadTopic: string;
@Column({
nullable: true,
type: "datetime",
comment: "วันเริ่มต้นการศึกษาดูงานต่างประเทศ",
default: null,
})
studyAbroadStartDate: Date;
@Column({
nullable: true,
type: "datetime",
comment: "วันสิ้นสุดการศึกษาดูงานต่างประเทศ",
default: null,
})
studyAbroadEndDate: Date;
@Column({
nullable: true,
comment: "รวมระยะเวลาในการศึกษา/รวมระยะเวลาในการฝึกอบรม",
length: 40,
default: null,
})
totalPeriod: string;
@Column({
// ในแผนฯ (INPLAN)
// นอกแผนฯ (OUTPLAN)
nullable: true,
comment: "ในแผนฯ",
length: 40,
default: null,
})
planType: string;
@Column({
comment: "ไม่ใช้งบประมาณ",
default: false,
})
isNoUseBudget: boolean;
@Column({
nullable: true,
comment: "เลขที่หนังสือรายงานตัวกลับเข้าปฏิบัติราชการ",
default: null,
})
bookNumber: string;
@Column({
nullable: true,
type: "datetime",
comment: " หนังสือรายงานตัวกลับเข้าปฏิบัติราชการลงวันที่",
default: null,
})
bookDate: Date;
@Column({
nullable: true,
type: "datetime",
comment: "วันที่กลับเข้าปฏิบัติราชการ",
default: null,
})
governmentDate: Date;
@Column({
nullable: true,
type: "datetime",
comment: "วันสิ้นสุดภาระผูกพัน",
default: null,
})
governmentEndDate: Date;
@Column({
comment: "สำเร็จการศึกษาตามที่หลักสูตรกำหนด",
default: false,
})
isGraduated: boolean;
@Column({
nullable: true,
type: "datetime",
comment: "ตั้งแต่",
default: null,
})
graduatedDate: Date;
@Column({
nullable: true,
comment: "เนื่องจาก",
default: null,
})
graduatedReason: string;
@Column({
nullable: true,
comment: "เงินอื่นๆ",
default: null,
})
budgetSourceOther: string;
}
export class CreateDevelopmentScholarship {
rootDnaId?: string | null;
rootId: string | null;
root: string | null;
org: string | null;
orgRootShortName: string | null;
orgRevisionId: string | null;
profileId: string | null;
rank?: string | null;
prefix: string | null;
firstName: string | null;
lastName: string | null;
citizenId: string | null;
position: string | null;
posExecutive: string | null;
posLevelId: string | null;
posTypeId: string | null;
guarantorRootDnaId?: string | null;
guarantorRootId: string | null;
guarantorRoot: string | null;
guarantorOrg: string | null;
guarantorOrgRootShortName: string | null;
guarantorOrgRevisionId: string | null;
guarantorRank?: string | null;
guarantorPrefix: string | null;
guarantorFirstName: string | null;
guarantorLastName: string | null;
guarantorCitizenId: string | null;
guarantorPosition: string | null;
guarantorPosExecutive: string | null;
posLevelguarantorId: string | null;
posTypeguarantorId: string | null;
scholarshipYear: number | null;
budgetSource: string | null;
budgetApprove: Double | null;
bookNo: string | null;
bookNoDate: Date | null;
bookApproveDate: Date | null;
useOfficialTime: string | null;
changeDetail: string | null;
scholarshipType: string | null;
fundType: string | null;
contractNo: string | null;
contractDate: Date | null;
reportBackNo: string | null;
reportBackNoDate: Date | null;
reportBackDate: Date | null;
degreeLevel: string | null;
course: string | null;
field: string | null;
faculty: string | null;
educationalInstitution: string | null;
startDate: Date | null;
endDate: Date | null;
studyPlace: string | null;
studyTopic: string | null;
studyStartDate: Date | null;
studyEndDate: Date | null;
studyCountry: string | null;
studyAbroadTopic: string | null;
studyAbroadStartDate: Date | null;
studyAbroadEndDate: Date | null;
totalPeriod: string | null;
planType: string | null;
isNoUseBudget: boolean | null;
budgetSourceOther?: string | null;
}
export class UpdateDevelopmentScholarship {
rootDnaId?: string | null;
rootId: string | null;
root: string | null;
org: string | null;
orgRootShortName: string | null;
orgRevisionId: string | null;
profileId: string | null;
rank?: string | null;
prefix: string | null;
firstName: string | null;
lastName: string | null;
citizenId: string | null;
position: string | null;
posExecutive: string | null;
posLevelId: string | null;
posTypeId: string | null;
guarantorRootDnaId?: string | null;
guarantorRootId?: string | null;
guarantorRoot?: string | null;
guarantorOrg?: string | null;
guarantorOrgRootShortName?: string | null;
guarantorOrgRevisionId?: string | null;
guarantorRank?: string | null;
guarantorPrefix: string | null;
guarantorFirstName: string | null;
guarantorLastName: string | null;
guarantorCitizenId: string | null;
guarantorPosition: string | null;
guarantorPosExecutive: string | null;
posLevelguarantorId: string | null;
posTypeguarantorId: string | null;
scholarshipYear: number | null;
budgetSource: string | null;
budgetApprove: Double | null;
bookNo: string | null;
bookNoDate: Date | null;
bookApproveDate: Date | null;
useOfficialTime: string | null;
changeDetail: string | null;
scholarshipType: string | null;
fundType: string | null;
contractNo: string | null;
contractDate: Date | null;
reportBackNo: string | null;
reportBackNoDate: Date | null;
reportBackDate: Date | null;
degreeLevel: string | null;
course: string | null;
field: string | null;
faculty: string | null;
educationalInstitution: string | null;
startDate: Date | null;
endDate: Date | null;
studyPlace: string | null;
studyTopic: string | null;
studyStartDate: Date | null;
studyEndDate: Date | null;
studyCountry: string | null;
studyAbroadTopic: string | null;
studyAbroadStartDate: Date | null;
studyAbroadEndDate: Date | null;
totalPeriod: string | null;
planType: string | null;
isNoUseBudget: boolean | null;
budgetSourceOther?: string | null;
}
export class UpdateDevelopmentScholarshipUser {
bookNumber: string | null;
bookDate: Date | null;
governmentDate: Date | null;
governmentEndDate: Date | null;
isGraduated: boolean | null;
graduatedDate: Date | null;
graduatedReason: string | null;
budgetSourceOther?: string | null;
}

View file

@ -0,0 +1,65 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { EmployeePosType } from "./EmployeePosType";
import { DevelopmentHistory } from "./DevelopmentHistory";
enum EmployeePosLevelAuthoritys {
HEAD = "HEAD",
DEPUTY = "DEPUTY",
GOVERNOR = "GOVERNOR",
}
@Entity("employeePosLevel")
export class EmployeePosLevel extends EntityBase {
@Column({
comment: "ชื่อระดับชั้นงาน",
type: "int",
})
posLevelName: number;
@Column({
comment: "ระดับของระดับชั้นงาน",
type: "int",
})
posLevelRank: number;
@Column({
nullable: true,
comment:
"ผู้มีอำนาจสั่งบรรจุของระดับนี้ head = หัวหน้าหน่วยงาน , deputy = ปลัด , governor = ผู้ว่าฯ",
type: "enum",
enum: EmployeePosLevelAuthoritys,
default: null,
})
posLevelAuthority: EmployeePosLevelAuthoritys;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง employeePosType",
})
posTypeId: string;
@ManyToOne(() => EmployeePosType, (posType: EmployeePosType) => posType.posLevels)
@JoinColumn({ name: "posTypeId" })
posType: EmployeePosType;
@OneToMany(() => DevelopmentHistory, (developmentHistory) => developmentHistory.employeePosLevel)
developmentHistorys: DevelopmentHistory[];
}
export class CreateEmployeePosLevel {
@Column()
posLevelName: number;
@Column()
posLevelRank: number;
@Column()
posLevelAuthority: string;
@Column("uuid")
posTypeId: string;
}
export type UpdateEmployeePosLevel = Partial<CreateEmployeePosLevel> & {
posLevelAuthority: EmployeePosLevelAuthoritys;
};

View file

@ -0,0 +1,47 @@
import { Entity, Column, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { EmployeePosLevel } from "./EmployeePosLevel";
import { DevelopmentHistory } from "./DevelopmentHistory";
@Entity("employeePosType")
export class EmployeePosType extends EntityBase {
@Column({
nullable: true,
comment: "ชื่อกลุ่มงาน",
length: 255,
default: null,
})
posTypeName: string;
@Column({
comment: "ระดับของกลุ่มงาน",
})
posTypeRank: number;
@Column({
nullable: true,
comment: "ชื่อย่อกลุ่มงาน",
length: 255,
default: null,
})
posTypeShortName: string;
@OneToMany(() => EmployeePosLevel, (posLevel: EmployeePosLevel) => posLevel.posType)
posLevels: EmployeePosLevel[];
@OneToMany(() => DevelopmentHistory, (developmentHistory) => developmentHistory.employeePosType)
developmentHistorys: DevelopmentHistory[];
}
export class CreateEmployeePosType {
@Column()
posTypeName: string;
@Column()
posTypeRank: number;
@Column()
posTypeShortName: string;
}
export type UpdateEmployeePosType = Partial<CreateEmployeePosType>;

100
src/entities/PlannedGoal.ts Normal file
View file

@ -0,0 +1,100 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { Development } from "./Development";
import { CreatePlannedGoalPosition, PlannedGoalPosition } from "./PlannedGoalPosition";
@Entity("plannedGoal")
export class PlannedGoal extends EntityBase {
@Column({
nullable: true,
comment: "กลุ่มเป้าหมาย",
default: null,
})
groupTarget: string;
@Column({
nullable: true,
comment: "กลุ่มเป้าหมายย่อย",
default: null,
})
groupTargetSub: string;
// @Column({
// nullable: true,
// comment: "ตำแหน่ง",
// default: null,
// })
// position: string;
// @Column({
// nullable: true,
// comment: "ประเภทตำแหน่ง",
// default: null,
// })
// posTypePlannedId: string;
// @ManyToOne(() => PosType, (posType: PosType) => posType.plannedGoals)
// @JoinColumn({ name: "posTypePlannedId" })
// posTypePlanned: PosType;
// @Column({
// nullable: true,
// comment: "ระดับตำแหน่ง",
// default: null,
// })
// posLevelPlannedId: string;
// @ManyToOne(() => PosLevel, (posLevel: PosLevel) => posLevel.plannedGoals)
// @JoinColumn({ name: "posLevelPlannedId" })
// posLevelPlanned: PosLevel;
@Column({
nullable: true,
comment: "ประเภท(กลุ่มอาชีพ คุณสมบัติ)",
default: null,
})
type: string;
@Column({
nullable: true,
comment: "จำนวน(คน)",
default: null,
})
amount: number;
@Column({
nullable: true,
comment: "id โครงการ",
default: null,
})
developmentPlannedGoalId: string;
@ManyToOne(() => Development, (development: Development) => development.developmentPlannedGoals)
@JoinColumn({ name: "developmentPlannedGoalId" })
developmentPlannedGoal: Development;
@OneToMany(
() => PlannedGoalPosition,
(plannedGoalPosition: PlannedGoalPosition) => plannedGoalPosition.plannedGoal,
)
plannedGoalPositions: PlannedGoalPosition[];
}
export class CreatePlannedGoal {
@Column()
groupTarget: string | null;
@Column()
groupTargetSub: string | null;
@Column()
positions: CreatePlannedGoalPosition[];
// @Column()
// posTypePlannedId: string | null;
// @Column()
// posLevelPlannedId: string | null;
@Column()
type: string | null;
@Column()
amount: number | null;
}
export type UpdatePlannedGoal = Partial<CreatePlannedGoal>;

View file

@ -0,0 +1,86 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { PosType } from "./PosType";
import { PosLevel } from "./PosLevel";
import { PlannedGoal } from "./PlannedGoal";
@Entity("plannedGoalPosition")
export class PlannedGoalPosition extends EntityBase {
@Column({
nullable: true,
comment: "ตำแหน่ง",
default: null,
})
position: string;
@Column({
nullable: true,
comment: "ตำแหน่งทางการบริหาร",
default: null,
})
posExecutive: string;
@Column({
nullable: true,
comment: "ประเภทตำแหน่ง & กลุ่มงาน",
default: null,
})
posTypePlanned: string;
// @Column({
// nullable: true,
// comment: "ประเภทตำแหน่ง",
// default: null,
// })
// posTypePlannedId: string;
// @ManyToOne(() => PosType, (posType: PosType) => posType.plannedGoalPositions)
// @JoinColumn({ name: "posTypePlannedId" })
// posTypePlanned: PosType;
@Column({
nullable: true,
comment: "ระดับตำแหน่ง & ระดับชั้นงาน",
default: null,
})
posLevelPlanned: string;
// @Column({
// nullable: true,
// comment: "ระดับตำแหน่ง",
// default: null,
// })
// posLevelPlannedId: string;
// @ManyToOne(() => PosLevel, (posLevel: PosLevel) => posLevel.plannedGoalPositions)
// @JoinColumn({ name: "posLevelPlannedId" })
// posLevelPlanned: PosLevel;
@Column({
nullable: true,
comment: "id โครงการ",
default: null,
})
plannedGoalId: string;
@ManyToOne(() => PlannedGoal, (plannedGoal: PlannedGoal) => plannedGoal.plannedGoalPositions)
@JoinColumn({ name: "plannedGoalId" })
plannedGoal: PlannedGoal;
}
export class CreatePlannedGoalPosition {
@Column()
position: string | null;
@Column()
posExecutive: string | null;
// @Column()
// posTypePlannedId: string | null;
// @Column()
// posLevelPlannedId: string | null;
@Column()
posTypePlanned: string | null;
@Column()
posLevelPlanned: string | null;
}
export type UpdatePlannedGoalPosition = Partial<CreatePlannedGoalPosition>;

View file

@ -0,0 +1,40 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { Development } from "./Development";
@Entity("plannedPeople")
export class PlannedPeople extends EntityBase {
@Column({
nullable: true,
comment: "ผู้เกี่ยวข้อง",
default: null,
})
groupTarget: string;
@Column({
nullable: true,
comment: "จำนวน(คน)",
default: null,
})
amount: number;
@Column({
nullable: true,
comment: "id โครงการ",
default: null,
})
developmentPlannedPeopleId: string;
@ManyToOne(() => Development, (development: Development) => development.developmentPlannedPeoples)
@JoinColumn({ name: "developmentPlannedPeopleId" })
developmentPlannedPeople: Development;
}
export class CreatePlannedPeople {
@Column()
groupTarget: string | null;
@Column()
amount: number | null;
}
export type UpdatePlannedPeople = Partial<CreatePlannedPeople>;

26
src/entities/Portfolio.ts Normal file
View file

@ -0,0 +1,26 @@
import { Entity, Column } from "typeorm";
import { EntityBase } from "./base/Base";
@Entity("portfolio")
export class Portfolio extends EntityBase {
@Column({
nullable: true,
comment: "ชื่อเอกสาร/ผลงาน",
default: null,
})
name: string;
@Column({
type: "longtext",
nullable: true,
comment: "รายละเอียดเอกสาร/ผลงาน",
default: null,
})
detail: string;
}
export class CreatePortfolio {
@Column()
name: string;
@Column()
detail: string | null;
}

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

@ -0,0 +1,90 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { PosType } from "./PosType";
import { ActualGoal } from "./ActualGoal";
import { DevelopmentHistory } from "./DevelopmentHistory";
import { DevelopmentScholarship } from "./DevelopmentScholarship";
import { PlannedGoalPosition } from "./PlannedGoalPosition";
enum PosLevelAuthority {
HEAD = "HEAD",
DEPUTY = "DEPUTY",
GOVERNOR = "GOVERNOR",
}
@Entity("posLevel")
export class PosLevel extends EntityBase {
@Column({
nullable: true,
comment: "ชื่อระดับตำแหน่ง",
length: 255,
default: null,
})
posLevelName: string;
@Column({
nullable: true,
comment: "ระดับของระดับตำแหน่ง",
default: null,
})
posLevelRank: number;
@Column({
nullable: true,
comment:
"ผู้มีอำนาจสั่งบรรจุของระดับนี้ head = หัวหน้าหน่วยงาน , deputy = ปลัด , governor = ผู้ว่าฯ",
type: "enum",
enum: PosLevelAuthority,
default: null,
})
posLevelAuthority: PosLevelAuthority;
@Column({
length: 40,
comment: "เป็นระดับของประเภทตำแหน่งใด",
})
posTypeId: string;
@ManyToOne(() => PosType, (posType: PosType) => posType.posLevels)
@JoinColumn({ name: "posTypeId" })
posType: PosType;
// @OneToMany(() => ActualGoal, (actualGoal: ActualGoal) => actualGoal.posLevelActual)
// actualGoals: ActualGoal[];
// @OneToMany(
// () => PlannedGoalPosition,
// (plannedGoalPosition: PlannedGoalPosition) => plannedGoalPosition.posLevelPlanned,
// )
// plannedGoalPositions: PlannedGoalPosition[];
@OneToMany(() => DevelopmentHistory, (developmentHistory) => developmentHistory.posLevel)
developmentHistorys: DevelopmentHistory[];
@OneToMany(
() => DevelopmentScholarship,
(developmentScholarship) => developmentScholarship.posLevel,
)
developmentScholars: DevelopmentScholarship[];
@OneToMany(
() => DevelopmentScholarship,
(developmentScholarship) => developmentScholarship.posLevelguarantor,
)
developmentScholarGuarantors: DevelopmentScholarship[];
}
export class CreatePosLevel {
@Column()
posLevelName: string;
@Column()
posLevelRank: number;
@Column()
posLevelAuthority: string;
@Column("uuid")
posTypeId: string;
}
export type UpdatePosLevel = Partial<CreatePosLevel> & { posLevelAuthority?: PosLevelAuthority };

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

@ -0,0 +1,64 @@
import { Entity, Column, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { PosLevel } from "./PosLevel";
import { ActualGoal } from "./ActualGoal";
import { PlannedGoal } from "./PlannedGoal";
import { DevelopmentHistory } from "./DevelopmentHistory";
import { DevelopmentScholarship } from "./DevelopmentScholarship";
import { PlannedGoalPosition } from "./PlannedGoalPosition";
@Entity("posType")
export class PosType extends EntityBase {
@Column({
nullable: true,
comment: "ชื่อประเภทตำแหน่ง (ทั่วไป วิชาการ อำนวยการ บริหาร)",
length: 255,
default: null,
})
posTypeName: string;
@Column({
nullable: true,
comment:
"ระดับของประเภทตำแหน่ง ไว้ใช้ระบุว่าประเภทตำแหน่งนี้อยู่ระดับสูงหรือต่ำกว่ากัน โดย 1 = ต่ำกว่า , มากกว่า 1 = สูงกว่า ทั่วไป = 1 วิชาการ = 2 อำนวยการ = 3 บริหาร = 4",
default: null,
})
posTypeRank: number;
@OneToMany(() => PosLevel, (posLevel: PosLevel) => posLevel.posType)
posLevels: PosLevel[];
// @OneToMany(() => ActualGoal, (actualGoal: ActualGoal) => actualGoal.posTypeActual)
// actualGoals: ActualGoal[];
// @OneToMany(
// () => PlannedGoalPosition,
// (plannedGoalPosition: PlannedGoalPosition) => plannedGoalPosition.posTypePlanned,
// )
// plannedGoalPositions: PlannedGoalPosition[];
@OneToMany(() => DevelopmentHistory, (developmentHistory) => developmentHistory.posType)
developmentHistorys: DevelopmentHistory[];
@OneToMany(
() => DevelopmentScholarship,
(developmentScholarship) => developmentScholarship.posType,
)
developmentScholars: DevelopmentScholarship[];
@OneToMany(
() => DevelopmentScholarship,
(developmentScholarship) => developmentScholarship.posTypeguarantor,
)
developmentScholarGuarantors: DevelopmentScholarship[];
}
export class CreatePosType {
@Column()
posTypeName: string;
@Column()
posTypeRank: number;
}
export type UpdatePosType = Partial<CreatePosType>;

23
src/entities/Province.ts Normal file
View file

@ -0,0 +1,23 @@
import { Entity, Column, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { Development } from "./Development";
import { DevelopmentAddress } from "./DevelopmentAddress";
import { DevelopmentOther } from "./DevelopmentOther";
@Entity("province")
export class Province extends EntityBase {
@Column({
nullable: true,
comment: "จังหวัด",
length: 255,
default: null,
})
name: string;
}
export class CreateProvince {
@Column()
name: string;
}
export type UpdateProvince = Partial<CreateProvince>;

View file

@ -0,0 +1,49 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToMany, PrimaryGeneratedColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { StrategyChild2 } from "./StrategyChild2";
import { StrategyChild3 } from "./StrategyChild3";
import { StrategyChild4 } from "./StrategyChild4";
import { StrategyChild5 } from "./StrategyChild5";
import { Development } from "./Development";
@Entity("strategyChild1")
export class StrategyChild1 extends EntityBase {
@Column({
nullable: true,
comment: "ชื่อยุทธศาสตร์",
length: 255,
default: null,
})
strategyChild1Name: string;
@Column({
nullable: true,
comment: "ลำดับความสำคัญ",
default: null,
})
order: number;
@OneToMany(() => StrategyChild2, (strategyChild2) => strategyChild2.strategyChild1)
strategyChild2s: StrategyChild2[];
@OneToMany(() => StrategyChild3, (strategyChild3) => strategyChild3.strategyChild1)
strategyChild3s: StrategyChild3[];
@OneToMany(() => StrategyChild4, (strategyChild4) => strategyChild4.strategyChild1)
strategyChild4s: StrategyChild4[];
@OneToMany(() => StrategyChild5, (strategyChild5) => strategyChild5.strategyChild1)
strategyChild5s: StrategyChild5[];
@OneToMany(() => Development, (development) => development.strategyChild1Planned)
developmentPlanneds: Development[];
@OneToMany(() => Development, (development) => development.strategyChild1Actual)
developmentActuals: Development[];
}
export class CreateStrategyChild1 {
@Column()
strategyChild1Name: string;
}
export type UpdateStrategyChild1 = Partial<CreateStrategyChild1>;

View file

@ -0,0 +1,59 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToMany, PrimaryGeneratedColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { StrategyChild1 } from "./StrategyChild1";
import { StrategyChild3 } from "./StrategyChild3";
import { StrategyChild4 } from "./StrategyChild4";
import { StrategyChild5 } from "./StrategyChild5";
import { Development } from "./Development";
@Entity("strategyChild2")
export class StrategyChild2 extends EntityBase {
@Column({
nullable: true,
comment: "ชื่อยุทธศาสตร์/แผน",
length: 255,
default: null,
})
strategyChild2Name: string;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild1",
})
strategyChild1Id: string;
@Column({
nullable: true,
comment: "ลำดับความสำคัญ",
default: null,
})
order: number;
@ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild2s)
@JoinColumn({ name: "strategyChild1Id" })
strategyChild1: StrategyChild1;
@OneToMany(() => StrategyChild3, (strategyChild3) => strategyChild3.strategyChild2)
strategyChild3s: StrategyChild3[];
@OneToMany(() => StrategyChild4, (strategyChild4) => strategyChild4.strategyChild2)
strategyChild4s: StrategyChild4[];
@OneToMany(() => StrategyChild5, (strategyChild5) => strategyChild5.strategyChild2)
strategyChild5s: StrategyChild5[];
@OneToMany(() => Development, (development) => development.strategyChild2Planned)
developmentPlanneds: Development[];
@OneToMany(() => Development, (development) => development.strategyChild2Actual)
developmentActuals: Development[];
}
export class CreateStrategyChild2 {
@Column()
strategyChild2Name: string;
@Column("uuid")
strategyChild1Id: string;
}
export type UpdateStrategyChild2 = Partial<CreateStrategyChild2>;

View file

@ -0,0 +1,66 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToMany, PrimaryGeneratedColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { StrategyChild1 } from "./StrategyChild1";
import { StrategyChild2 } from "./StrategyChild2";
import { StrategyChild4 } from "./StrategyChild4";
import { StrategyChild5 } from "./StrategyChild5";
import { Development } from "./Development";
@Entity("strategyChild3")
export class StrategyChild3 extends EntityBase {
@Column({
nullable: true,
comment: "ยุทธศาสตร์ที่",
length: 255,
default: null,
})
strategyChild3Name: string;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild1",
})
strategyChild1Id: string;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild2",
})
strategyChild2Id: string;
@Column({
nullable: true,
comment: "ลำดับความสำคัญ",
default: null,
})
order: number;
@ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild3s)
@JoinColumn({ name: "strategyChild1Id" })
strategyChild1: StrategyChild1;
@ManyToOne(() => StrategyChild2, (strategyChild2) => strategyChild2.strategyChild3s)
@JoinColumn({ name: "strategyChild2Id" })
strategyChild2: StrategyChild2;
@OneToMany(() => StrategyChild4, (strategyChild4) => strategyChild4.strategyChild3)
strategyChild4s: StrategyChild4[];
@OneToMany(() => StrategyChild5, (strategyChild5) => strategyChild5.strategyChild3)
strategyChild5s: StrategyChild5[];
@OneToMany(() => Development, (development) => development.strategyChild3Planned)
developmentPlanneds: Development[];
@OneToMany(() => Development, (development) => development.strategyChild3Actual)
developmentActuals: Development[];
}
export class CreateStrategyChild3 {
@Column()
strategyChild3Name: string;
@Column("uuid")
strategyChild2Id: string;
}
export type UpdateStrategyChild3 = Partial<CreateStrategyChild3>;

View file

@ -0,0 +1,73 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToMany, PrimaryGeneratedColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { StrategyChild1 } from "./StrategyChild1";
import { StrategyChild2 } from "./StrategyChild2";
import { StrategyChild3 } from "./StrategyChild3";
import { StrategyChild5 } from "./StrategyChild5";
import { Development } from "./Development";
@Entity("strategyChild4")
export class StrategyChild4 extends EntityBase {
@Column({
nullable: true,
comment: "ยุทธศาสตร์ย่อยที่",
length: 255,
default: null,
})
strategyChild4Name: string;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild1",
})
strategyChild1Id: string;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild2",
})
strategyChild2Id: string;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild3",
})
strategyChild3Id: string;
@Column({
nullable: true,
comment: "ลำดับความสำคัญ",
default: null,
})
order: number;
@ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild4s)
@JoinColumn({ name: "strategyChild1Id" })
strategyChild1: StrategyChild1;
@ManyToOne(() => StrategyChild2, (strategyChild2) => strategyChild2.strategyChild4s)
@JoinColumn({ name: "strategyChild2Id" })
strategyChild2: StrategyChild2;
@ManyToOne(() => StrategyChild3, (strategyChild3) => strategyChild3.strategyChild4s)
@JoinColumn({ name: "strategyChild3Id" })
strategyChild3: StrategyChild3;
@OneToMany(() => StrategyChild5, (strategyChild5) => strategyChild5.strategyChild4)
strategyChild5s: StrategyChild5[];
@OneToMany(() => Development, (development) => development.strategyChild4Planned)
developmentPlanneds: Development[];
@OneToMany(() => Development, (development) => development.strategyChild4Actual)
developmentActuals: Development[];
}
export class CreateStrategyChild4 {
@Column()
strategyChild4Name: string;
@Column("uuid")
strategyChild3Id: string;
}
export type UpdateStrategyChild4 = Partial<CreateStrategyChild4>;

View file

@ -0,0 +1,80 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToMany, PrimaryGeneratedColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { StrategyChild1 } from "./StrategyChild1";
import { StrategyChild2 } from "./StrategyChild2";
import { StrategyChild3 } from "./StrategyChild3";
import { StrategyChild4 } from "./StrategyChild4";
import { Development } from "./Development";
@Entity("strategyChild5")
export class StrategyChild5 extends EntityBase {
@Column({
nullable: true,
comment: "กลยุทธ์ที่/เป้าประสงค์ที่",
length: 255,
default: null,
})
strategyChild5Name: string;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild1",
})
strategyChild1Id: string;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild2",
})
strategyChild2Id: string;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild3",
})
strategyChild3Id: string;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild4",
})
strategyChild4Id: string;
@Column({
nullable: true,
comment: "ลำดับความสำคัญ",
default: null,
})
order: number;
@ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild5s)
@JoinColumn({ name: "strategyChild1Id" })
strategyChild1: StrategyChild1;
@ManyToOne(() => StrategyChild2, (strategyChild2) => strategyChild2.strategyChild5s)
@JoinColumn({ name: "strategyChild2Id" })
strategyChild2: StrategyChild2;
@ManyToOne(() => StrategyChild3, (strategyChild3) => strategyChild3.strategyChild5s)
@JoinColumn({ name: "strategyChild3Id" })
strategyChild3: StrategyChild3;
@ManyToOne(() => StrategyChild4, (strategyChild4) => strategyChild4.strategyChild5s)
@JoinColumn({ name: "strategyChild4Id" })
strategyChild4: StrategyChild4;
@OneToMany(() => Development, (development) => development.strategyChild5Planned)
developmentPlanneds: Development[];
@OneToMany(() => Development, (development) => development.strategyChild5Actual)
developmentActuals: Development[];
}
export class CreateStrategyChild5 {
@Column()
strategyChild5Name: string;
@Column("uuid")
strategyChild4Id: string;
}
export type UpdateStrategyChild5 = Partial<CreateStrategyChild5>;

View file

@ -0,0 +1,28 @@
import { ViewColumn, ViewEntity } from "typeorm";
@ViewEntity({
expression: `SELECT MAX(\`rootId\`) AS rootId,
MAX(\`root\`) AS root,\`degreeLevel\`,
COUNT(*) AS numberOfRecords,
COUNT(DISTINCT \`scholarshipType\`) AS numberOfScholarshipTypes,
SUM(\`budgetApprove\`) AS totalBudgetApprove
FROM \`developmentScholarship\`
GROUP BY \`rootId\`,\`degreeLevel\`
`,
})
export class viewDevScholarship {
@ViewColumn()
rootId: string;
@ViewColumn()
root: string;
@ViewColumn()
degreeLevel: string;
@ViewColumn()
numberOfRecords: number;
@ViewColumn()
numberOfScholarshipTypes: number;
@ViewColumn()
totalBudgetApprove: number;
}

View file

@ -0,0 +1,84 @@
import { Path } from "tsoa";
import axios from "axios";
import { addLogSequence } from "./utils";
class CallAPI {
//Get
public async GetData(request: any, @Path() path: any, log = true) {
const token = "Bearer " + request.headers.authorization.replace("Bearer ", "");
const url = process.env.API_URL + path;
try {
const response = await axios.get(url, {
headers: {
Authorization: `${token}`,
"Content-Type": "application/json",
api_key: process.env.API_KEY,
},
});
if(log) addLogSequence(request, {
action: "request",
status: "success",
description: "connected",
request: {
method: "GET",
url: url,
response: JSON.stringify(response.data.result),
},
});
return response.data.result;
} catch (error) {
if(log) addLogSequence(request, {
action: "request",
status: "error",
description: "unconnected",
request: {
method: "GET",
url: url,
response: JSON.stringify(error),
},
});
throw error;
}
}
//Post
public async PostData(request: any, @Path() path: any, sendData: any) {
const token = "Bearer " + request.headers.authorization.replace("Bearer ", "");
const url = process.env.API_URL + path;
try {
const response = await axios.post(url, sendData, {
headers: {
Authorization: `${token}`,
"Content-Type": "application/json",
api_key: process.env.API_KEY,
},
});
addLogSequence(request, {
action: "request",
status: "success",
description: "connected",
request: {
method: "POST",
url: url,
payload: JSON.stringify(sendData),
response: JSON.stringify(response.data.result),
},
});
return response.data.result;
} catch (error) {
addLogSequence(request, {
action: "request",
status: "error",
description: "unconnected",
request: {
method: "POST",
url: url,
payload: JSON.stringify(sendData),
response: JSON.stringify(error),
},
});
throw error;
}
}
}
export default CallAPI;

134
src/interfaces/extension.ts Normal file
View file

@ -0,0 +1,134 @@
class Extension {
public static ToThaiMonth(value: number) {
switch (value) {
case 1:
return "มกราคม";
case 2:
return "กุมภาพันธ์";
case 3:
return "มีนาคม";
case 4:
return "เมษายน";
case 5:
return "พฤษภาคม";
case 6:
return "มิถุนายน";
case 7:
return "กรกฎาคม";
case 8:
return "สิงหาคม";
case 9:
return "กันยายน";
case 10:
return "ตุลาคม";
case 11:
return "พฤศจิกายน";
case 12:
return "ธันวาคม";
default:
return "";
}
}
public static ToThaiShortMonth(value: number) {
switch (value) {
case 1:
return "ม.ค.";
case 2:
return "ก.พ.";
case 3:
return "มี.ค.";
case 4:
return "เม.ย.";
case 5:
return "พ.ค.";
case 6:
return "มิ.ย.";
case 7:
return "ก.ค.";
case 8:
return "ส.ค.";
case 9:
return "ก.ย.";
case 10:
return "ต.ค.";
case 11:
return "พ.ย.";
case 12:
return "ธ.ค.";
default:
return "";
}
}
public static ToThaiYear(value: number) {
if (value < 2400) return value + 543;
else return value;
}
public static ToCeYear(value: number) {
if (value >= 2400) return value - 543;
else return value;
}
public static ToThaiNumber(value: string) {
let arabicNumbers = "0123456789";
let thaiNumbers = "๐๑๒๓๔๕๖๗๘๙";
let result = "";
for (let digit of value) {
let index = arabicNumbers.indexOf(digit);
if (index >= 0) {
result += thaiNumbers[index];
} else {
result += digit;
}
}
return result;
}
public static ToThaiFullDate(value: Date) {
let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear();
return (
"วันที่ " +
value.getDate() +
" เดือน " +
Extension.ToThaiMonth(value.getMonth() + 1) +
" พ.ศ. " +
yy
);
}
public static ToThaiFullDate2(value: Date) {
let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear();
return value.getDate() + " " + Extension.ToThaiMonth(value.getMonth() + 1) + " " + yy;
}
public static ToThaiFullDate3(value: Date) {
let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear();
return value.getDate() + " เดือน " + Extension.ToThaiMonth(value.getMonth() + 1) + " พ.ศ. " + yy;
}
public static sumObjectValues(array: any, propertyName: any) {
let sum = 0;
for (let i = 0; i < array.length; i++) {
if (array[i][propertyName] !== undefined) {
sum += array[i][propertyName];
}
}
return sum;
}
public static ToThaiShortDate(value: Date) {
let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear();
return (
value.getDate() +
" " +
Extension.ToThaiShortMonth(value.getMonth() + 1) +
" " +
yy.toString().slice(-2)
);
}
}
export default Extension;

View file

@ -1,4 +1,6 @@
import { RequestWithUser } from "../middlewares/user";
import HttpStatus from "./http-status";
import { addLogSequence } from "./utils";
class HttpSuccess {
/**
@ -14,5 +16,4 @@ class HttpSuccess {
this.result = result;
}
}
export default HttpSuccess;

View file

@ -0,0 +1,292 @@
import axios from "axios";
import { RequestWithUser } from "../middlewares/user";
import CallAPI from "./call-api";
import HttpError from "./http-error";
import HttpStatus from "./http-status";
import { promisify } from "util";
class CheckAuth {
private redis = require("redis");
public async Permission(req: RequestWithUser, system: string, action: string) {
if (
req.headers.hasOwnProperty("api_key") &&
req.headers["api_key"] &&
req.headers["api_key"] == process.env.API_KEY
) {
return null;
}
return await new CallAPI()
.GetData(req, "/org/permission")
.then((x) => {
let permission = false;
let role = x.roles.find((x: any) => x.authSysId == system);
if (!role) throw "ไม่มีสิทธิ์เข้าระบบ";
if (role.attrOwnership == "OWNER") return "OWNER";
if (action.trim().toLocaleUpperCase() == "CREATE") permission = role.attrIsCreate;
if (action.trim().toLocaleUpperCase() == "DELETE") permission = role.attrIsDelete;
if (action.trim().toLocaleUpperCase() == "GET") permission = role.attrIsGet;
if (action.trim().toLocaleUpperCase() == "LIST") permission = role.attrIsList;
if (action.trim().toLocaleUpperCase() == "UPDATE") permission = role.attrIsUpdate;
if (permission == false) throw "ไม่มีสิทธิ์ใช้งานระบบนี้";
return role.attrPrivilege;
})
.catch((x) => {
if (x.status != undefined) {
throw new HttpError(x.status, x.message);
} else {
throw new HttpError(HttpStatus.FORBIDDEN, x);
}
});
}
public async PermissionOrg(req: RequestWithUser, system: string, action: string) {
if (
req.headers.hasOwnProperty("api_key") &&
req.headers["api_key"] &&
req.headers["api_key"] == process.env.API_KEY
) {
return {
root: null,
child1: null,
child2: null,
child3: null,
child4: null,
};
}
return await new CallAPI()
.GetData(req, `/org/permission/org/${system}/${action}`)
.then(async (x) => {
let privilege = x.privilege;
let data: any = {
root: [null],
child1: [null],
child2: [null],
child3: [null],
child4: [null],
privilege: [null],
};
let node = 4;
if (x.orgChild1Id == null) {
node = 0;
} else if (x.orgChild2Id == null) {
node = 1;
} else if (x.orgChild3Id == null) {
node = 2;
} else if (x.orgChild4Id == null) {
node = 3;
}
if (privilege == "OWNER") {
data = {
root: null,
child1: null,
child2: null,
child3: null,
child4: null,
privilege: "OWNER",
};
} else if (privilege == "ROOT") {
data = {
root: [x.orgRootId],
child1: null,
child2: null,
child3: null,
child4: null,
privilege: "ROOT",
};
} else if (privilege == "CHILD") {
data = {
root: node >= 0 ? [x.orgRootId] : null,
child1: node >= 1 ? [x.orgChild1Id] : null,
child2: node >= 2 ? [x.orgChild2Id] : null,
child3: node >= 3 ? [x.orgChild3Id] : null,
child4: node >= 4 ? [x.orgChild4Id] : null,
privilege: "CHILD",
};
} else if (privilege == "NORMAL") {
data = {
root: [x.orgRootId],
child1: [x.orgChild1Id],
child2: [x.orgChild2Id],
child3: [x.orgChild3Id],
child4: [x.orgChild4Id],
privilege: "NORMAL",
};
} else if (privilege == "SPECIFIC") {
}
return data;
})
.catch((x) => {
if (x.status != undefined) {
throw new HttpError(x.status, x.message);
} else {
throw new HttpError(HttpStatus.FORBIDDEN, x);
}
});
}
public async PermissionOrgByUser(
req: RequestWithUser,
system: string,
action: string,
profileId: string,
) {
if (
req.headers.hasOwnProperty("api_key") &&
req.headers["api_key"] &&
req.headers["api_key"] == process.env.API_KEY
) {
return true;
}
return await new CallAPI()
.GetData(req, `/org/permission/user/${system}/${action}/${profileId}`)
.then(async (x) => {
let org = x.org;
if (org.root != null) if (x.orgRootId != org.root[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล";
if (org.child1 != null)
if (x.orgChild1Id != org.child1[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล";
if (org.child2 != null)
if (x.orgChild2Id != org.child2[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล";
if (org.child3 != null)
if (x.orgChild3Id != org.child3[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล";
if (org.child4 != null)
if (x.orgChild4Id != org.child4[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล";
return true;
})
.catch((x) => {
if (x.status != undefined) {
throw new HttpError(x.status, x.message);
} else {
throw new HttpError(HttpStatus.FORBIDDEN, x);
}
});
}
public async Workflow(req: RequestWithUser, id: string, sysName: string) {
if (
req.headers.hasOwnProperty("api_key") &&
req.headers["api_key"] &&
req.headers["api_key"] == process.env.API_KEY
) {
return null;
}
return await new CallAPI()
.PostData(req, "/org/workflow/keycloak/isofficer", {
refId: id,
sysName: sysName,
})
.then((x) => {
return true;
})
.catch((x) => {
return false;
});
}
public async checkOrg(token: any, keycloakId: string) {
try {
// Validate required environment variables
const REDIS_HOST = process.env.REDIS_HOST;
const REDIS_PORT = process.env.REDIS_PORT ? Number(process.env.REDIS_PORT) : 6379;
if (!REDIS_HOST) {
throw new Error("REDIS_HOST is not set in environment variables");
}
console.log(`[REDIS] Connecting to Redis at ${REDIS_HOST}:${REDIS_PORT}`);
// Create Redis client
const redisClient = this.redis.createClient({
socket: {
host: REDIS_HOST,
port: REDIS_PORT,
},
});
redisClient.on("error", (err: any) => {
console.error("[REDIS] Connection error:", err.message);
});
await redisClient.connect();
console.log("[REDIS] Connected successfully!");
const getAsync = promisify(redisClient.get).bind(redisClient);
let reply = await getAsync("org_" + keycloakId);
if (reply != null) {
reply = JSON.parse(reply);
} else {
if (!keycloakId) throw new Error("No KeycloakId provided");
const x = await new CallAPI().GetData(
{
headers: { authorization: token },
},
`/org/permission/checkOrg/${keycloakId}`,
false,
);
const data = {
orgRootId: x.orgRootId,
orgChild1Id: x.orgChild1Id,
orgChild2Id: x.orgChild2Id,
orgChild3Id: x.orgChild3Id,
orgChild4Id: x.orgChild4Id,
};
return data;
}
} catch (error) {
console.error("Error calling API:", error);
throw error;
}
}
public async PermissionCreate(req: RequestWithUser, system: string) {
return await this.Permission(req, system, "CREATE");
}
public async PermissionDelete(req: RequestWithUser, system: string) {
return await this.Permission(req, system, "DELETE");
}
public async PermissionGet(req: RequestWithUser, system: string) {
return await this.Permission(req, system, "GET");
}
public async PermissionList(req: RequestWithUser, system: string) {
return await this.Permission(req, system, "LIST");
}
public async PermissionUpdate(req: RequestWithUser, system: string) {
return await this.Permission(req, system, "UPDATE");
}
public async PermissionOrgCreate(req: RequestWithUser, system: string) {
return await this.PermissionOrg(req, system, "CREATE");
}
public async PermissionOrgDelete(req: RequestWithUser, system: string) {
return await this.PermissionOrg(req, system, "DELETE");
}
public async PermissionOrgGet(req: RequestWithUser, system: string) {
return await this.PermissionOrg(req, system, "GET");
}
public async PermissionOrgList(req: RequestWithUser, system: string) {
return await this.PermissionOrg(req, system, "LIST");
}
public async PermissionOrgUpdate(req: RequestWithUser, system: string) {
return await this.PermissionOrg(req, system, "UPDATE");
}
public async PermissionOrgUserCreate(req: RequestWithUser, system: string, profileId: string) {
return await this.PermissionOrgByUser(req, system, "CREATE", profileId);
}
public async PermissionOrgUserDelete(req: RequestWithUser, system: string, profileId: string) {
return await this.PermissionOrgByUser(req, system, "DELETE", profileId);
}
public async PermissionOrgUserGet(req: RequestWithUser, system: string, profileId: string) {
return await this.PermissionOrgByUser(req, system, "GET", profileId);
}
public async PermissionOrgUserList(req: RequestWithUser, system: string, profileId: string) {
return await this.PermissionOrgByUser(req, system, "LIST", profileId);
}
public async PermissionOrgUserUpdate(req: RequestWithUser, system: string, profileId: string) {
return await this.PermissionOrgByUser(req, system, "UPDATE", profileId);
}
}
export default CheckAuth;

View file

@ -0,0 +1,39 @@
export interface StorageFolder {
/**
* @prop Full path to this folder. It is used as key as there are no files or directories at the same location.
*/
pathname: string;
/**
* @prop Directory / Folder name.
*/
name: string;
createdAt: string | Date;
createdBy: string | Date;
}
export interface StorageFile {
/**
* @prop Full path to this folder. It is used as key as there are no files or directories at the same location.
*/
pathname: string;
fileName: string;
fileSize: number;
fileType: string;
title: string;
description: string;
author: string;
category: string[];
keyword: string[];
metadata: Record<string, unknown>;
path: string;
upload: boolean;
updatedAt: string | Date;
updatedBy: string;
createdAt: string | Date;
createdBy: string;
}

47
src/interfaces/utils.ts Normal file
View file

@ -0,0 +1,47 @@
import { RequestWithUser } from "../middlewares/user";
export type DataDiff = {
before: any;
after: any;
};
export type LogSequence = {
action: string;
status: "success" | "error";
description: string;
query?: any;
request?: {
method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
url?: string;
payload?: string;
response?: string;
};
};
export function setLogDataDiff(req: RequestWithUser, data: DataDiff) {
// Check if data.before and data.after are valid objects
if (
data.before &&
typeof data.before === "object" &&
data.after &&
typeof data.after === "object"
) {
req.app.locals.logData.dataDiff = {
before: JSON.stringify(data.before),
after: JSON.stringify(data.after),
};
} else {
console.error("Invalid data provided: both before and after must be valid objects.");
}
}
export function addLogSequence(req: RequestWithUser, data: LogSequence) {
if (!req?.app?.locals?.logData?.sequence) {
req.app.locals.logData.sequence = [];
}
req.app.locals.logData.sequence = req.app.locals.logData.sequence.concat(data);
}
export function editLogSequence(req: RequestWithUser, index: number, data: LogSequence) {
req.app.locals.logData.sequence[index] = data;
}

View file

@ -3,15 +3,13 @@ import { createDecoder, createVerifier } from "fast-jwt";
import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status";
import { addLogSequence } from "../interfaces/utils";
import { RequestWithUser } from "./user";
if (!process.env.AUTH_PUBLIC_KEY && !process.env.AUTH_REALM_URL) {
throw new Error("Require keycloak AUTH_PUBLIC_KEY or AUTH_REALM_URL.");
}
if (
process.env.AUTH_PUBLIC_KEY &&
process.env.AUTH_REALM_URL &&
!process.env.AUTH_PREFERRED_MODE
) {
if (process.env.AUTH_PUBLIC_KEY && process.env.AUTH_REALM_URL && !process.env.AUTH_PREFERRED_MODE) {
throw new Error(
"AUTH_PREFFERRED must be specified if AUTH_PUBLIC_KEY and AUTH_REALM_URL is provided.",
);
@ -26,7 +24,7 @@ const jwtVerify = createVerifier({
const jwtDecode = createDecoder();
export async function expressAuthentication(
request: express.Request,
request: RequestWithUser,
securityName: string,
_scopes?: string[],
) {
@ -56,6 +54,18 @@ export async function expressAuthentication(
if (process.env.AUTH_PUBLIC_KEY) payload = await verifyOffline(token);
break;
}
if (!request.app.locals.logData) {
request.app.locals.logData = {};
}
// addLogSequence(request, {
// action: "database",
// status: "success",
// description: "Query Data.",
// });
request.app.locals.logData.userId = payload.sub;
request.app.locals.logData.userName = payload.name;
request.app.locals.logData.user = payload.preferred_username;
return payload;
}

View file

@ -4,6 +4,12 @@ import HttpStatus from "../interfaces/http-status";
import { ValidateError } from "tsoa";
function error(error: Error, _req: Request, res: Response, _next: NextFunction) {
const logData = _req.app.locals.logData.sequence?.at(-1);
if (logData) {
logData.status = "error";
logData.description = error.message;
}
if (error instanceof HttpError) {
return res.status(error.status).json({
status: error.status,

90
src/middlewares/logs.ts Normal file
View file

@ -0,0 +1,90 @@
import { NextFunction, Request, Response } from "express";
import { Client } from "@elastic/elasticsearch";
import permission from "../interfaces/permission";
if (!process.env.ELASTICSEARCH_INDEX) {
throw new Error("Require ELASTICSEARCH_INDEX to store log.");
}
const ELASTICSEARCH_INDEX = process.env.ELASTICSEARCH_INDEX;
const LOG_LEVEL_MAP: Record<string, number> = {
debug: 4,
info: 3,
warning: 2,
error: 1,
none: 0,
};
const elasticsearch = new Client({
node: `${process.env.ELASTICSEARCH_PROTOCOL}://${process.env.ELASTICSEARCH_HOST}:${process.env.ELASTICSEARCH_PORT}`,
});
async function logMiddleware(req: Request, res: Response, next: NextFunction) {
if (!req.url.startsWith("/api/")) return next();
let data: any;
const originalJson = res.json;
res.json = function (v: any) {
data = v;
return originalJson.call(this, v);
};
const timestamp = new Date().toISOString();
const start = performance.now();
req.app.locals.logData = {};
res.on("finish", async () => {
try {
if (!req.url.startsWith("/api/")) return;
const level = LOG_LEVEL_MAP[process.env.LOG_LEVEL ?? "debug"] || 4;
if (level === 1 && res.statusCode < 500) return;
if (level === 2 && res.statusCode < 400) return;
if (level === 3 && res.statusCode < 200) return;
const token = req.headers["authorization"];
let rootId = null;
try {
rootId = token
? await new permission().checkOrg(token, req.app.locals.logData.userId)
: null;
} catch (err) {
console.warn("Error fetching rootId:", err);
}
const obj = {
logType: res.statusCode >= 500 ? "error" : res.statusCode >= 400 ? "warning" : "info",
ip: req.ip,
rootId: rootId?.orgRootId ?? null,
systemName: "development",
startTimeStamp: timestamp,
endTimeStamp: new Date().toISOString(),
processTime: performance.now() - start,
host: req.hostname,
method: req.method,
endpoint: req.url,
responseCode: String(res.statusCode === 304 ? 200 : res.statusCode),
responseDescription: data?.message,
input: level === 4 ? JSON.stringify(req.body, null, 2) : undefined,
output: level === 4 ? JSON.stringify(data, null, 2) : undefined,
...req.app.locals.logData,
};
// Send log to Elasticsearch
await elasticsearch.index({
index: ELASTICSEARCH_INDEX,
document: obj,
});
} catch (err) {
console.error("Error in logMiddleware:", err);
}
});
return next();
}
export default logMiddleware;

13
src/middlewares/user.ts Normal file
View file

@ -0,0 +1,13 @@
import type { Request } from "express";
export type RequestWithUser = Request & {
user: {
sub: string;
name: string;
given_name: string;
familiy_name: string;
preferred_username: string;
email: string;
role: string[];
};
};

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableDevelopment1712050402784 implements MigrationInterface {
name = 'AddTableDevelopment1712050402784'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE \`development\` (\`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', \`name\` varchar(255) NOT NULL COMMENT 'ชื่อโครงการ/กิจกรรม/หลักสูตร', \`year\` int NULL COMMENT 'ปีงบประมาณ', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP TABLE \`development\``);
}
}

View file

@ -0,0 +1,128 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableDevelopment1712060108057 implements MigrationInterface {
name = 'AddTableDevelopment1712060108057'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE \`actualPeople\` (\`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', \`groupTarget\` varchar(255) NULL COMMENT 'ผู้เกี่ยวข้อง', \`amount\` int NULL COMMENT 'จำนวน(คน)', \`developmentActualPeopleId\` varchar(255) NULL COMMENT 'id โครงการ', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`plannedPeople\` (\`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', \`groupTarget\` varchar(255) NULL COMMENT 'ผู้เกี่ยวข้อง', \`amount\` int NULL COMMENT 'จำนวน(คน)', \`developmentPlannedPeopleId\` varchar(255) NULL COMMENT 'id โครงการ', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`plannedGoal\` (\`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', \`groupTarget\` varchar(255) NULL COMMENT 'กลุ่มเป้าหมาย', \`groupTargetSub\` varchar(255) NULL COMMENT 'กลุ่มเป้าหมายย่อย', \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง', \`posTypePlannedId\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง', \`posLevelPlannedId\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง', \`type\` varchar(255) NULL COMMENT 'ประเภท(กลุ่มอาชีพ คุณสมบัติ)', \`amount\` int NULL COMMENT 'จำนวน(คน)', \`developmentPlannedGoalId\` varchar(255) NULL COMMENT 'id โครงการ', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`posType\` (\`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', \`posTypeName\` varchar(255) NULL COMMENT 'ชื่อประเภทตำแหน่ง (ทั่วไป วิชาการ อำนวยการ บริหาร)', \`posTypeRank\` int NULL COMMENT 'ระดับของประเภทตำแหน่ง ไว้ใช้ระบุว่าประเภทตำแหน่งนี้อยู่ระดับสูงหรือต่ำกว่ากัน โดย 1 = ต่ำกว่า , มากกว่า 1 = สูงกว่า ทั่วไป = 1 วิชาการ = 2 อำนวยการ = 3 บริหาร = 4', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`posLevel\` (\`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', \`posLevelName\` varchar(255) NULL COMMENT 'ชื่อระดับตำแหน่ง', \`posLevelRank\` int NULL COMMENT 'ระดับของระดับตำแหน่ง', \`posLevelAuthority\` enum ('HEAD', 'DEPUTY', 'GOVERNOR') NULL COMMENT 'ผู้มีอำนาจสั่งบรรจุของระดับนี้ head = หัวหน้าหน่วยงาน , deputy = ปลัด , governor = ผู้ว่าฯ', \`posTypeId\` varchar(40) NOT NULL COMMENT 'เป็นระดับของประเภทตำแหน่งใด', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`actualGoal\` (\`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', \`groupTarget\` varchar(255) NULL COMMENT 'กลุ่มเป้าหมาย', \`groupTargetSub\` varchar(255) NULL COMMENT 'กลุ่มเป้าหมายย่อย', \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง', \`posTypeActualId\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง', \`posLevelActualId\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง', \`type\` varchar(255) NULL COMMENT 'ประเภท(กลุ่มอาชีพ คุณสมบัติ)', \`amount\` int NULL COMMENT 'จำนวน(คน)', \`developmentActualGoalId\` varchar(255) NULL COMMENT 'id โครงการ', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`province\` (\`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', \`name\` varchar(255) NULL COMMENT 'จังหวัด', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`employeePosType\` (\`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', \`posTypeName\` varchar(255) NULL COMMENT 'ชื่อกลุ่มงาน', \`posTypeRank\` int NOT NULL COMMENT 'ระดับของกลุ่มงาน', \`posTypeShortName\` varchar(255) NULL COMMENT 'ชื่อย่อกลุ่มงาน', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`employeePosLevel\` (\`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', \`posLevelName\` int NOT NULL COMMENT 'ชื่อระดับชั้นงาน', \`posLevelRank\` int NOT NULL COMMENT 'ระดับของระดับชั้นงาน', \`posLevelAuthority\` enum ('HEAD', 'DEPUTY', 'GOVERNOR') NULL COMMENT 'ผู้มีอำนาจสั่งบรรจุของระดับนี้ head = หัวหน้าหน่วยงาน , deputy = ปลัด , governor = ผู้ว่าฯ', \`posTypeId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง employeePosType', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`name\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectName\` varchar(255) NOT NULL COMMENT 'ชื่อโครงการ/กิจกรรม/หลักสูตร'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`reason\` varchar(255) NULL COMMENT 'หลักการและเหตุผล'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`objective\` varchar(255) NULL COMMENT 'วัตถุประสงค์'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`metricType\` varchar(255) NULL COMMENT 'ประเภทตัวชี้วัด'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`indicators\` varchar(255) NULL COMMENT 'ตัวชี้วัด'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`target\` varchar(255) NULL COMMENT 'เป้าหมาย'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`calculation\` varchar(255) NULL COMMENT 'วิธีการคำนวณ/เครื่องมือ'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`measuRement\` varchar(255) NULL COMMENT 'ระยะเวลาวัดผล'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`results\` varchar(255) NULL COMMENT 'ผลการดำเนิน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`obstacles\` varchar(255) NULL COMMENT 'ปัญหาอุปสรรค'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`suggestions\` varchar(255) NULL COMMENT 'ข้อเสนอเเนะ'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`project\` varchar(255) NULL COMMENT 'ประเภทโครงการ'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isPassAllocate\` tinyint NOT NULL COMMENT 'ผ่านการพิจาณา ได้รับการจัดสรรงบประมาณตามข้อบัญญัติ' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isPassNoAllocate\` tinyint NOT NULL COMMENT 'ผ่านการพิจารณา ไม่ได้รับการจัดสรรงบประมาณตามข้อบัญญัติ แต่ได้รับการจัดสรรเงินนอกงบประมาณ' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isNoPass\` tinyint NOT NULL COMMENT 'ไม่ผ่านการพิจารณา แต่ได้รับการจัดสรรเงินนอกงบประมาณ' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isBudget\` tinyint NOT NULL COMMENT 'แต่ได้รับการจัดสรรงบประมาณตามข้อบัญญัติ' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isOutBudget\` tinyint NOT NULL COMMENT 'แต่ได้รับการจัดสรรเงินนอกงบประมาณ' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`dateStart\` datetime NULL COMMENT 'วันที่เริ่มต้น'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`dateEnd\` datetime NULL COMMENT 'วันที่สิ้นสุด'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`totalDate\` int NULL COMMENT 'รวมระยะเวลา (วัน)'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`address\` varchar(255) NULL COMMENT 'ที่อยู่'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`provinceId\` varchar(255) NULL COMMENT 'จังหวัด'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`budget\` varchar(255) NULL COMMENT 'ประเภทงบประมาณ'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`accept\` double NULL COMMENT 'จํานวนงบประมาณที่ขอรับการจัดสรรฯ' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`receive\` double NULL COMMENT 'จํานวนงบประมาณที่ได้รับการจัดสรรฯ' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`approved\` double NULL COMMENT 'จํานวนงบประมาณที่ได้รับอนุมัติ' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`budgetPay\` double NULL COMMENT 'จํานวนงบประมาณที่จ่ายจริง' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`issues\` varchar(255) NULL COMMENT 'ประเด็นความเสี่ยง'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`chance\` varchar(255) NULL COMMENT 'โอกาศที่จะเกิด'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`effects\` varchar(255) NULL COMMENT 'ผลกระทบจากการเกิด'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`riskLevel\` varchar(255) NULL COMMENT 'ระดับความเสี่ยง'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`riskManagement\` varchar(255) NULL COMMENT 'เเนวทางการบริหารความเสี่ยง'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`expect\` varchar(255) NULL COMMENT 'ประโยชน์ที่คาดว่าจะได้รับ'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`topicAcademic\` varchar(255) NULL COMMENT 'หัวข้อ/ประเด็นการฝึกอบรม ศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`addressAcademic\` varchar(255) NULL COMMENT 'สถานที่ฝึกอบรม ศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`provinceActualId\` varchar(255) NULL COMMENT 'จังหวัด(ข้อมูลวิชาการ)'`);
await queryRunner.query(`ALTER TABLE \`actualPeople\` ADD CONSTRAINT \`FK_f829036b60eabcca870d5e9242e\` FOREIGN KEY (\`developmentActualPeopleId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`plannedPeople\` ADD CONSTRAINT \`FK_b508fdcde0693754799a9a75603\` FOREIGN KEY (\`developmentPlannedPeopleId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`plannedGoal\` ADD CONSTRAINT \`FK_308d02f616b878261a3890b4d40\` FOREIGN KEY (\`posTypePlannedId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`plannedGoal\` ADD CONSTRAINT \`FK_0e6aba627301f35aa3570b44bf5\` FOREIGN KEY (\`posLevelPlannedId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`plannedGoal\` ADD CONSTRAINT \`FK_14f48058eff5d24c8be711ae92b\` FOREIGN KEY (\`developmentPlannedGoalId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`posLevel\` ADD CONSTRAINT \`FK_66caa3d974b67a8a8b343d029b2\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD CONSTRAINT \`FK_e08e337e5ddeb4942c72393ff58\` FOREIGN KEY (\`posTypeActualId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD CONSTRAINT \`FK_a9a864dd06eaa25edba8be8f24c\` FOREIGN KEY (\`posLevelActualId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD CONSTRAINT \`FK_5fc0017c134049b436d20ee81b4\` FOREIGN KEY (\`developmentActualGoalId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_c7552b4624cc7347144be758e6e\` FOREIGN KEY (\`provinceId\`) REFERENCES \`province\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_bdafbb824b88c3bdb73adf7f220\` FOREIGN KEY (\`provinceActualId\`) REFERENCES \`province\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`employeePosLevel\` ADD CONSTRAINT \`FK_7fb9ab868f3f46b44f460c984f1\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`employeePosType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`employeePosLevel\` DROP FOREIGN KEY \`FK_7fb9ab868f3f46b44f460c984f1\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_bdafbb824b88c3bdb73adf7f220\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_c7552b4624cc7347144be758e6e\``);
await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP FOREIGN KEY \`FK_5fc0017c134049b436d20ee81b4\``);
await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP FOREIGN KEY \`FK_a9a864dd06eaa25edba8be8f24c\``);
await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP FOREIGN KEY \`FK_e08e337e5ddeb4942c72393ff58\``);
await queryRunner.query(`ALTER TABLE \`posLevel\` DROP FOREIGN KEY \`FK_66caa3d974b67a8a8b343d029b2\``);
await queryRunner.query(`ALTER TABLE \`plannedGoal\` DROP FOREIGN KEY \`FK_14f48058eff5d24c8be711ae92b\``);
await queryRunner.query(`ALTER TABLE \`plannedGoal\` DROP FOREIGN KEY \`FK_0e6aba627301f35aa3570b44bf5\``);
await queryRunner.query(`ALTER TABLE \`plannedGoal\` DROP FOREIGN KEY \`FK_308d02f616b878261a3890b4d40\``);
await queryRunner.query(`ALTER TABLE \`plannedPeople\` DROP FOREIGN KEY \`FK_b508fdcde0693754799a9a75603\``);
await queryRunner.query(`ALTER TABLE \`actualPeople\` DROP FOREIGN KEY \`FK_f829036b60eabcca870d5e9242e\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`provinceActualId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`addressAcademic\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`topicAcademic\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`expect\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`riskManagement\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`riskLevel\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`effects\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`chance\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`issues\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`budgetPay\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`approved\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`receive\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`accept\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`budget\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`provinceId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`address\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`totalDate\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`dateEnd\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`dateStart\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isOutBudget\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isBudget\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isNoPass\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isPassNoAllocate\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isPassAllocate\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`project\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`suggestions\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`obstacles\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`results\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`measuRement\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`calculation\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`target\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`indicators\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`metricType\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`objective\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reason\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectName\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`name\` varchar(255) NOT NULL COMMENT 'ชื่อโครงการ/กิจกรรม/หลักสูตร'`);
await queryRunner.query(`DROP TABLE \`employeePosLevel\``);
await queryRunner.query(`DROP TABLE \`employeePosType\``);
await queryRunner.query(`DROP TABLE \`province\``);
await queryRunner.query(`DROP TABLE \`actualGoal\``);
await queryRunner.query(`DROP TABLE \`posLevel\``);
await queryRunner.query(`DROP TABLE \`posType\``);
await queryRunner.query(`DROP TABLE \`plannedGoal\``);
await queryRunner.query(`DROP TABLE \`plannedPeople\``);
await queryRunner.query(`DROP TABLE \`actualPeople\``);
}
}

View file

@ -0,0 +1,22 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableDevelopmentHistory1712076616416 implements MigrationInterface {
name = 'AddTableDevelopmentHistory1712076616416'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE \`developmentHistory\` (\`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', \`rank\` varchar(40) NULL COMMENT 'ยศ', \`prefix\` varchar(40) NULL COMMENT 'คำนำหน้าชื่อ', \`firstName\` varchar(255) NULL COMMENT 'ชื่อ', \`lastName\` varchar(255) NULL COMMENT 'นามสกุล', \`citizenId\` varchar(13) NULL COMMENT 'เลขประจำตัวประชาชน', \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง', \`posLevelId\` varchar(40) NULL COMMENT 'ไอดีระดับตำแหน่ง', \`posTypeId\` varchar(40) NULL COMMENT 'ไอดีประเภทตำแหน่ง', \`developmentId\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`ALTER TABLE \`development\` CHANGE \`chance\` \`chance\` varchar(255) NULL COMMENT 'โอกาสที่จะเกิด'`);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD CONSTRAINT \`FK_d786f60dffba2d9a24c3bd3921b\` FOREIGN KEY (\`posLevelId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD CONSTRAINT \`FK_d4e7a95f885bd0bd26c9ec1dba2\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD CONSTRAINT \`FK_405574443eb92d4cdd8a88a22e6\` FOREIGN KEY (\`developmentId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP FOREIGN KEY \`FK_405574443eb92d4cdd8a88a22e6\``);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP FOREIGN KEY \`FK_d4e7a95f885bd0bd26c9ec1dba2\``);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP FOREIGN KEY \`FK_d786f60dffba2d9a24c3bd3921b\``);
await queryRunner.query(`ALTER TABLE \`development\` CHANGE \`chance\` \`chance\` varchar(255) NULL COMMENT 'โอกาศที่จะเกิด'`);
await queryRunner.query(`DROP TABLE \`developmentHistory\``);
}
}

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableDevelopmentHistory11712078526676 implements MigrationInterface {
name = 'AddTableDevelopmentHistory11712078526676'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`order\` varchar(255) NULL COMMENT 'เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ'`);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`dateOrder\` varchar(255) NULL COMMENT 'คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`dateOrder\``);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`order\``);
}
}

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableDevelopmentHistory21712119650901 implements MigrationInterface {
name = 'AddTableDevelopmentHistory21712119650901'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`type\` varchar(40) NULL COMMENT 'ประเภทราชการ'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`type\``);
}
}

View file

@ -0,0 +1,20 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevelopmentHistoryAddType1712120794817 implements MigrationInterface {
name = 'UpdateTableDevelopmentHistoryAddType1712120794817'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`employeePosLevelId\` varchar(40) NULL COMMENT 'ไอดีระดับตำแหน่ง'`);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`employeePosTypeId\` varchar(40) NULL COMMENT 'ไอดีประเภทตำแหน่ง'`);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD CONSTRAINT \`FK_a905f077069e27d2fc9bb8f5f5c\` FOREIGN KEY (\`employeePosLevelId\`) REFERENCES \`employeePosLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD CONSTRAINT \`FK_25dd3134b725bb2ec455872374f\` FOREIGN KEY (\`employeePosTypeId\`) REFERENCES \`employeePosType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP FOREIGN KEY \`FK_25dd3134b725bb2ec455872374f\``);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP FOREIGN KEY \`FK_a905f077069e27d2fc9bb8f5f5c\``);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`employeePosTypeId\``);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`employeePosLevelId\``);
}
}

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevelopmentHistoryAddType11712126314212 implements MigrationInterface {
name = 'UpdateTableDevelopmentHistoryAddType11712126314212'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`posExecutive\` varchar(255) NULL COMMENT 'ชื่อตำแหน่งทางการบริหาร'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`posExecutive\``);
}
}

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevelopmentAddDateStudyStart1712135164363 implements MigrationInterface {
name = 'UpdateTableDevelopmentAddDateStudyStart1712135164363'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` ADD \`dateStudyStart\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`dateStudyEnd\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษาดูงาน'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`dateStudyEnd\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`dateStudyStart\``);
}
}

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevelopmentAddDateStudyStart11712135296648 implements MigrationInterface {
name = 'UpdateTableDevelopmentAddDateStudyStart11712135296648'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`dateOrder\``);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`dateOrder\` datetime NULL COMMENT 'คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`dateOrder\``);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`dateOrder\` varchar(255) NULL COMMENT 'คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่'`);
}
}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,98 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableDevscholar11712235509538 implements MigrationInterface {
name = 'AddTableDevscholar11712235509538'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`courseOfStudy\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`dateOrder\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`fieldOfStudy\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`order\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourAbroadEndDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourAbroadStartDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourAbroadTopic\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourCountry\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourEndDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourPlace\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourStartDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourTopic\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`totalStudyPeriod\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`totalTrainingTime\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`trainingCourseName\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`trainingEndDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`trainingStartDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`posLevelId\` varchar(40) NULL COMMENT 'ไอดีระดับตำแหน่ง'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`posTypeId\` varchar(40) NULL COMMENT 'ไอดีประเภทตำแหน่ง'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`posLevelguarantorId\` varchar(40) NULL COMMENT 'ไอดีระดับตำแหน่ง(ผู้ค้ำ)'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`posTypeguarantorId\` varchar(40) NULL COMMENT 'ไอดีประเภทตำแหน่ง(ผู้ค้ำ)'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`course\` varchar(255) NULL COMMENT 'หลักสูตรการศึกษา/หลักสูตรการฝึกอบรม'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`field\` varchar(255) NULL COMMENT 'สาขาวิชา/สาขา'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`startDate\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษา/วันเริ่มต้นการฝึกอบรม/วันเริ่มต้นการศึกษาดูงานในประเทศ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`endDate\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษา/วันสิ้นสุดการฝึกอบรม/วันสิ้นสุดการศึกษาดูงานในประเทศ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyPlace\` varchar(255) NULL COMMENT 'สถานที่ไปศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTopic\` varchar(255) NULL COMMENT 'หัวข้อการไปศึกษาดูงาน/หัวข้อการไปศึกษาดูงานในประเทศ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyCountry\` varchar(255) NULL COMMENT 'ประเทศที่เดินทางไปศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyAbroadTopic\` varchar(255) NULL COMMENT 'หัวข้อการไปศึกษาดูงานต่างประเทศ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyAbroadStartDate\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษาดูงานต่างประเทศ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyAbroadEndDate\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษาดูงานต่างประเทศ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`totalPeriod\` varchar(40) NULL COMMENT 'รวมระยะเวลาในการศึกษา/รวมระยะเวลาในการฝึกอบรม'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`degreeLevel\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`degreeLevel\` varchar(255) NULL COMMENT 'ระดับปริญญา'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` CHANGE \`educationalInstitution\` \`educationalInstitution\` varchar(255) NULL COMMENT 'สถาบันการศึกษา/สถาบันการศึกษา_หน่วยงานผู้จัดการฝึกอบรม/สถานที่ไปศึกษาดูงานในประเทศ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyStartDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyStartDate\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyEndDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyEndDate\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD CONSTRAINT \`FK_c95a104dc1c147cd9ffe676097a\` FOREIGN KEY (\`posLevelId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD CONSTRAINT \`FK_4f93cbcfe04f319f043ca6bafe8\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD CONSTRAINT \`FK_264f2b2fc644c7173484c3b67d9\` FOREIGN KEY (\`posLevelguarantorId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD CONSTRAINT \`FK_5a83bbe2bac1e79113df21ed6ef\` FOREIGN KEY (\`posTypeguarantorId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP FOREIGN KEY \`FK_5a83bbe2bac1e79113df21ed6ef\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP FOREIGN KEY \`FK_264f2b2fc644c7173484c3b67d9\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP FOREIGN KEY \`FK_4f93cbcfe04f319f043ca6bafe8\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP FOREIGN KEY \`FK_c95a104dc1c147cd9ffe676097a\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyEndDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyEndDate\` varchar(255) NULL COMMENT 'วันสิ้นสุดการศึกษา'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyStartDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyStartDate\` varchar(255) NULL COMMENT 'วันเริ่มต้นการศึกษา'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` CHANGE \`educationalInstitution\` \`educationalInstitution\` varchar(255) NULL COMMENT 'สถาบันการศึกษา'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`degreeLevel\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`degreeLevel\` varchar(10) NULL COMMENT 'ระดับปริญญา'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`totalPeriod\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyAbroadEndDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyAbroadStartDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyAbroadTopic\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyCountry\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTopic\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyPlace\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`endDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`startDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`field\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`course\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`posTypeguarantorId\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`posLevelguarantorId\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`posTypeId\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`posLevelId\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`trainingStartDate\` date NULL COMMENT 'วันเริ่มต้นการฝึกอบรม'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`trainingEndDate\` date NULL COMMENT 'วันสิ้นสุดการฝึกอบรม'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`trainingCourseName\` varchar(255) NULL COMMENT 'หลักสูตรการฝึกอบรม'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`totalTrainingTime\` varchar(40) NULL COMMENT 'รวมระยะเวลาในการฝึกอบรม'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`totalStudyPeriod\` varchar(40) NULL COMMENT 'รวมระยะเวลาในการศึกษา'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourTopic\` datetime NULL COMMENT 'หัวข้อการไปศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourStartDate\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourPlace\` datetime NULL COMMENT 'สถานที่ไปศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourEndDate\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourCountry\` varchar(255) NULL COMMENT 'ประเทศที่เดินทางไปศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourAbroadTopic\` varchar(255) NULL COMMENT 'หัวข้อการไปศึกษาดูงานต่างประเทศ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourAbroadStartDate\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษาดูงานต่างประเทศ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourAbroadEndDate\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษาดูงานต่างประเทศ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`order\` varchar(255) NULL COMMENT 'เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`fieldOfStudy\` varchar(255) NULL COMMENT 'สาขาวิชา'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`dateOrder\` datetime NULL COMMENT 'คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`courseOfStudy\` varchar(255) NULL COMMENT 'หลักสูตรการศึกษา'`);
}
}

View file

@ -0,0 +1,60 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevelopementAddProjectType1712670681087 implements MigrationInterface {
name = 'UpdateTableDevelopementAddProjectType1712670681087'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`plannedGoal\` DROP FOREIGN KEY \`FK_0e6aba627301f35aa3570b44bf5\``);
await queryRunner.query(`ALTER TABLE \`plannedGoal\` DROP FOREIGN KEY \`FK_308d02f616b878261a3890b4d40\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_c7552b4624cc7347144be758e6e\``);
await queryRunner.query(`CREATE TABLE \`plannedGoalPosition\` (\`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', \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง', \`posTypePlannedId\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง', \`posLevelPlannedId\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง', \`plannedGoalId\` varchar(255) NULL COMMENT 'id โครงการ', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`province_development_provinces_development\` (\`provinceId\` varchar(36) NOT NULL, \`developmentId\` varchar(36) NOT NULL, INDEX \`IDX_32e044775dec4423645a09d90e\` (\`provinceId\`), INDEX \`IDX_66246e941aca36d81e7c8e0c88\` (\`developmentId\`), PRIMARY KEY (\`provinceId\`, \`developmentId\`)) ENGINE=InnoDB`);
await queryRunner.query(`ALTER TABLE \`plannedGoal\` DROP COLUMN \`position\``);
await queryRunner.query(`ALTER TABLE \`plannedGoal\` DROP COLUMN \`posTypePlannedId\``);
await queryRunner.query(`ALTER TABLE \`plannedGoal\` DROP COLUMN \`posLevelPlannedId\``);
await queryRunner.query(`ALTER TABLE \`plannedGoal\` DROP COLUMN \`type\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`provinceId\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectType\` varchar(255) NULL COMMENT 'ประเภทโครงการ'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectCharacteristics\` varchar(255) NULL COMMENT 'ลักษณะ'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectDay\` int NULL COMMENT 'จำนวน(วัน)'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectNigth\` int NULL COMMENT 'จำนวน(คืน)'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectTechniques\` varchar(255) NULL COMMENT 'เทคนิควิธีการที่ใช้ในการพัฒนา'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectModal\` int NULL COMMENT 'จำนวน(รุ่น)'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`budgetSub\` varchar(255) NULL COMMENT 'ประเภทย่อย'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`status\` varchar(40) NULL COMMENT 'สถานะ' DEFAULT 'PENDING'`);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD CONSTRAINT \`FK_4eef5d8c3ab92f7af4a762150a4\` FOREIGN KEY (\`posTypePlannedId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD CONSTRAINT \`FK_8e7e0bf6eebd99f58e9b47c6b05\` FOREIGN KEY (\`posLevelPlannedId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD CONSTRAINT \`FK_f2fad93b1a4a3454f0de1c12c62\` FOREIGN KEY (\`plannedGoalId\`) REFERENCES \`plannedGoal\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`province_development_provinces_development\` ADD CONSTRAINT \`FK_32e044775dec4423645a09d90e6\` FOREIGN KEY (\`provinceId\`) REFERENCES \`province\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`);
await queryRunner.query(`ALTER TABLE \`province_development_provinces_development\` ADD CONSTRAINT \`FK_66246e941aca36d81e7c8e0c888\` FOREIGN KEY (\`developmentId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`province_development_provinces_development\` DROP FOREIGN KEY \`FK_66246e941aca36d81e7c8e0c888\``);
await queryRunner.query(`ALTER TABLE \`province_development_provinces_development\` DROP FOREIGN KEY \`FK_32e044775dec4423645a09d90e6\``);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP FOREIGN KEY \`FK_f2fad93b1a4a3454f0de1c12c62\``);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP FOREIGN KEY \`FK_8e7e0bf6eebd99f58e9b47c6b05\``);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP FOREIGN KEY \`FK_4eef5d8c3ab92f7af4a762150a4\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`status\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`budgetSub\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectModal\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectTechniques\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectNigth\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectDay\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectCharacteristics\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectType\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`provinceId\` varchar(255) NULL COMMENT 'จังหวัด'`);
await queryRunner.query(`ALTER TABLE \`plannedGoal\` ADD \`type\` varchar(255) NULL COMMENT 'ประเภท(กลุ่มอาชีพ คุณสมบัติ)'`);
await queryRunner.query(`ALTER TABLE \`plannedGoal\` ADD \`posLevelPlannedId\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง'`);
await queryRunner.query(`ALTER TABLE \`plannedGoal\` ADD \`posTypePlannedId\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง'`);
await queryRunner.query(`ALTER TABLE \`plannedGoal\` ADD \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง'`);
await queryRunner.query(`DROP INDEX \`IDX_66246e941aca36d81e7c8e0c88\` ON \`province_development_provinces_development\``);
await queryRunner.query(`DROP INDEX \`IDX_32e044775dec4423645a09d90e\` ON \`province_development_provinces_development\``);
await queryRunner.query(`DROP TABLE \`province_development_provinces_development\``);
await queryRunner.query(`DROP TABLE \`plannedGoalPosition\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_c7552b4624cc7347144be758e6e\` FOREIGN KEY (\`provinceId\`) REFERENCES \`province\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`plannedGoal\` ADD CONSTRAINT \`FK_308d02f616b878261a3890b4d40\` FOREIGN KEY (\`posTypePlannedId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`plannedGoal\` ADD CONSTRAINT \`FK_0e6aba627301f35aa3570b44bf5\` FOREIGN KEY (\`posLevelPlannedId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
}

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableScholarshipAddProfileId1712721970803 implements MigrationInterface {
name = 'UpdateTableScholarshipAddProfileId1712721970803'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`profileId\` varchar(40) NULL COMMENT 'id profile'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`profileId\``);
}
}

View file

@ -0,0 +1,92 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevRefresh11712778363784 implements MigrationInterface {
name = 'UpdateTableDevRefresh11712778363784'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE \`developmentAddress\` (\`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', \`address\` varchar(255) NULL COMMENT 'ที่อยู่', \`provinceId\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม', \`developmentId\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`developmentProjectType\` (\`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', \`name\` varchar(255) NULL COMMENT 'ประเภทโครงการ', \`developmentId\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`developmentProjectTechnique\` (\`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', \`name\` varchar(255) NULL COMMENT 'เทคนิควิธีการที่ใช้ในการพัฒนา', \`developmentId\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`developmentEvaluation\` (\`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', \`indicators\` varchar(255) NULL COMMENT 'ตัวชี้วัด', \`target\` int NULL COMMENT 'เป้าหมาย', \`metricType\` varchar(255) NULL COMMENT 'ประเภทตัวชี้วัด', \`calculation\` varchar(255) NULL COMMENT 'วิธีการคำนวณ/เครื่องมือ', \`measuRement\` varchar(255) NULL COMMENT 'ระยะเวลาวัดผล', \`results\` varchar(255) NULL COMMENT 'ผลการดำเนิน', \`obstacles\` varchar(255) NULL COMMENT 'ปัญหาอุปสรรค', \`suggestions\` varchar(255) NULL COMMENT 'ข้อเสนอเเนะ', \`developmentId\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`metricType\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`indicators\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`target\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`calculation\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`measuRement\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`results\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`obstacles\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`suggestions\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`address\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`dateStudyStart\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`dateStudyEnd\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectType\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectCharacteristics\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectDay\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectNigth\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectTechniques\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`status\` varchar(255) NULL COMMENT 'สถานะ' DEFAULT 'ONGOING'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isBackPlanned\` tinyint NOT NULL COMMENT 'ไป-กลับ' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isHoldPlanned\` tinyint NOT NULL COMMENT 'พักค้าง' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectDayBackPlanned\` int NULL COMMENT 'จำนวน(วัน)(ไป-กลับ)'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectDayHoldPlanned\` int NULL COMMENT 'จำนวน(วัน)(พักค้าง)'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectNigthHoldPlanned\` int NULL COMMENT 'จำนวน(คืน)(พักค้าง)'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isBackActual\` tinyint NOT NULL COMMENT 'ไป-กลับ' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isHoldActual\` tinyint NOT NULL COMMENT 'พักค้าง' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectDayBackActual\` int NULL COMMENT 'จำนวน(วัน)(ไป-กลับ)'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectDayHoldActual\` int NULL COMMENT 'จำนวน(วัน)(พักค้าง)'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectNigthHoldActual\` int NULL COMMENT 'จำนวน(คืน)(พักค้าง)'`);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`chance\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`chance\` int NULL COMMENT 'โอกาสที่จะเกิด'`);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`effects\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`effects\` int NULL COMMENT 'ผลกระทบจากการเกิด'`);
await queryRunner.query(`ALTER TABLE \`developmentAddress\` ADD CONSTRAINT \`FK_e2721b3f440256b56ce83a04fb2\` FOREIGN KEY (\`provinceId\`) REFERENCES \`province\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`developmentAddress\` ADD CONSTRAINT \`FK_de5eb0e55892aa0cf019afb284d\` FOREIGN KEY (\`developmentId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`developmentProjectType\` ADD CONSTRAINT \`FK_e9c5a726024b87bb10f23570a98\` FOREIGN KEY (\`developmentId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`developmentProjectTechnique\` ADD CONSTRAINT \`FK_902408e69fa1cf0ed815859e089\` FOREIGN KEY (\`developmentId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`developmentEvaluation\` ADD CONSTRAINT \`FK_1714596cf3e3e8311a766800289\` FOREIGN KEY (\`developmentId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentEvaluation\` DROP FOREIGN KEY \`FK_1714596cf3e3e8311a766800289\``);
await queryRunner.query(`ALTER TABLE \`developmentProjectTechnique\` DROP FOREIGN KEY \`FK_902408e69fa1cf0ed815859e089\``);
await queryRunner.query(`ALTER TABLE \`developmentProjectType\` DROP FOREIGN KEY \`FK_e9c5a726024b87bb10f23570a98\``);
await queryRunner.query(`ALTER TABLE \`developmentAddress\` DROP FOREIGN KEY \`FK_de5eb0e55892aa0cf019afb284d\``);
await queryRunner.query(`ALTER TABLE \`developmentAddress\` DROP FOREIGN KEY \`FK_e2721b3f440256b56ce83a04fb2\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`effects\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`effects\` varchar(255) NULL COMMENT 'ผลกระทบจากการเกิด'`);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`chance\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`chance\` varchar(255) NULL COMMENT 'โอกาสที่จะเกิด'`);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectNigthHoldActual\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectDayHoldActual\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectDayBackActual\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isHoldActual\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isBackActual\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectNigthHoldPlanned\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectDayHoldPlanned\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectDayBackPlanned\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isHoldPlanned\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isBackPlanned\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`status\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectTechniques\` varchar(255) NULL COMMENT 'เทคนิควิธีการที่ใช้ในการพัฒนา'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectNigth\` int NULL COMMENT 'จำนวน(คืน)'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectDay\` int NULL COMMENT 'จำนวน(วัน)'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectCharacteristics\` varchar(255) NULL COMMENT 'ลักษณะ'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectType\` varchar(255) NULL COMMENT 'ประเภทโครงการ'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`dateStudyEnd\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`dateStudyStart\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`address\` varchar(255) NULL COMMENT 'ที่อยู่'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`suggestions\` varchar(255) NULL COMMENT 'ข้อเสนอเเนะ'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`obstacles\` varchar(255) NULL COMMENT 'ปัญหาอุปสรรค'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`results\` varchar(255) NULL COMMENT 'ผลการดำเนิน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`measuRement\` varchar(255) NULL COMMENT 'ระยะเวลาวัดผล'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`calculation\` varchar(255) NULL COMMENT 'วิธีการคำนวณ/เครื่องมือ'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`target\` varchar(255) NULL COMMENT 'เป้าหมาย'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`indicators\` varchar(255) NULL COMMENT 'ตัวชี้วัด'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`metricType\` varchar(255) NULL COMMENT 'ประเภทตัวชี้วัด'`);
await queryRunner.query(`DROP TABLE \`developmentEvaluation\``);
await queryRunner.query(`DROP TABLE \`developmentProjectTechnique\``);
await queryRunner.query(`DROP TABLE \`developmentProjectType\``);
await queryRunner.query(`DROP TABLE \`developmentAddress\``);
}
}

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevRefresh21712779710145 implements MigrationInterface {
name = 'UpdateTableDevRefresh21712779710145'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` ADD \`dateStudyStart\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`dateStudyEnd\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษาดูงาน'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`dateStudyEnd\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`dateStudyStart\``);
}
}

View file

@ -0,0 +1,42 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableStarty1712810427265 implements MigrationInterface {
name = 'AddTableStarty1712810427265'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE \`strategyChild4\` (\`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', \`strategyChild4Name\` varchar(255) NULL COMMENT 'ยุทธศาสตร์ย่อยที่', \`strategyChild1Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild1', \`strategyChild2Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild2', \`strategyChild3Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild3', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`strategyChild3\` (\`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', \`strategyChild3Name\` varchar(255) NULL COMMENT 'ยุทธศาสตร์ที่', \`strategyChild1Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild1', \`strategyChild2Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild2', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`strategyChild2\` (\`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', \`strategyChild2Name\` varchar(255) NULL COMMENT 'ชื่อยุทธศาสตร์/แผน', \`strategyChild1Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild1', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`strategyChild1\` (\`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', \`strategyChild1Name\` varchar(255) NULL COMMENT 'ชื่อยุทธศาสตร์', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`strategyChild5\` (\`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', \`strategyChild5Name\` varchar(255) NULL COMMENT 'กลยุทธ์ที่', \`strategyChild1Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild1', \`strategyChild2Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild2', \`strategyChild3Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild3', \`strategyChild4Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild4', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`ALTER TABLE \`strategyChild4\` ADD CONSTRAINT \`FK_0066b72a1b1e1832ee4e19f1962\` FOREIGN KEY (\`strategyChild1Id\`) REFERENCES \`strategyChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`strategyChild4\` ADD CONSTRAINT \`FK_f22f3637349caf8ba4e96bef6a6\` FOREIGN KEY (\`strategyChild2Id\`) REFERENCES \`strategyChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`strategyChild4\` ADD CONSTRAINT \`FK_a02975074aac7445aced33ab99d\` FOREIGN KEY (\`strategyChild3Id\`) REFERENCES \`strategyChild3\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`strategyChild3\` ADD CONSTRAINT \`FK_678c2b72214a00ba380affeb574\` FOREIGN KEY (\`strategyChild1Id\`) REFERENCES \`strategyChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`strategyChild3\` ADD CONSTRAINT \`FK_441c2fc2b760d1d0dfb9faca4bc\` FOREIGN KEY (\`strategyChild2Id\`) REFERENCES \`strategyChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`strategyChild2\` ADD CONSTRAINT \`FK_5dd11a1dac02f7368d6cd5bba34\` FOREIGN KEY (\`strategyChild1Id\`) REFERENCES \`strategyChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`strategyChild5\` ADD CONSTRAINT \`FK_2f396ec33e0f571a4e913ca30f3\` FOREIGN KEY (\`strategyChild1Id\`) REFERENCES \`strategyChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`strategyChild5\` ADD CONSTRAINT \`FK_2c2a8b73ea0fa93ebbd4d81229b\` FOREIGN KEY (\`strategyChild2Id\`) REFERENCES \`strategyChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`strategyChild5\` ADD CONSTRAINT \`FK_67d08068d52226bb028a0d25d36\` FOREIGN KEY (\`strategyChild3Id\`) REFERENCES \`strategyChild3\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`strategyChild5\` ADD CONSTRAINT \`FK_ad2b70c3a8955e67eec6ce85085\` FOREIGN KEY (\`strategyChild4Id\`) REFERENCES \`strategyChild4\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`strategyChild5\` DROP FOREIGN KEY \`FK_ad2b70c3a8955e67eec6ce85085\``);
await queryRunner.query(`ALTER TABLE \`strategyChild5\` DROP FOREIGN KEY \`FK_67d08068d52226bb028a0d25d36\``);
await queryRunner.query(`ALTER TABLE \`strategyChild5\` DROP FOREIGN KEY \`FK_2c2a8b73ea0fa93ebbd4d81229b\``);
await queryRunner.query(`ALTER TABLE \`strategyChild5\` DROP FOREIGN KEY \`FK_2f396ec33e0f571a4e913ca30f3\``);
await queryRunner.query(`ALTER TABLE \`strategyChild2\` DROP FOREIGN KEY \`FK_5dd11a1dac02f7368d6cd5bba34\``);
await queryRunner.query(`ALTER TABLE \`strategyChild3\` DROP FOREIGN KEY \`FK_441c2fc2b760d1d0dfb9faca4bc\``);
await queryRunner.query(`ALTER TABLE \`strategyChild3\` DROP FOREIGN KEY \`FK_678c2b72214a00ba380affeb574\``);
await queryRunner.query(`ALTER TABLE \`strategyChild4\` DROP FOREIGN KEY \`FK_a02975074aac7445aced33ab99d\``);
await queryRunner.query(`ALTER TABLE \`strategyChild4\` DROP FOREIGN KEY \`FK_f22f3637349caf8ba4e96bef6a6\``);
await queryRunner.query(`ALTER TABLE \`strategyChild4\` DROP FOREIGN KEY \`FK_0066b72a1b1e1832ee4e19f1962\``);
await queryRunner.query(`DROP TABLE \`strategyChild5\``);
await queryRunner.query(`DROP TABLE \`strategyChild1\``);
await queryRunner.query(`DROP TABLE \`strategyChild2\``);
await queryRunner.query(`DROP TABLE \`strategyChild3\``);
await queryRunner.query(`DROP TABLE \`strategyChild4\``);
}
}

View file

@ -0,0 +1,20 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableStarty11712815316667 implements MigrationInterface {
name = 'AddTableStarty11712815316667'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE \`developmentProjectTechniquePlanned\` (\`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', \`name\` varchar(255) NULL COMMENT 'เทคนิควิธีการที่ใช้ในการพัฒนา', \`developmentId\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`developmentProjectTechniqueActual\` (\`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', \`name\` varchar(255) NULL COMMENT 'เทคนิควิธีการที่ใช้ในการพัฒนา', \`developmentId\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`ALTER TABLE \`developmentProjectTechniquePlanned\` ADD CONSTRAINT \`FK_7166cc94112552ea072a2cc6134\` FOREIGN KEY (\`developmentId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`developmentProjectTechniqueActual\` ADD CONSTRAINT \`FK_aaaee1c5fb44bef093ed78a0c32\` FOREIGN KEY (\`developmentId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentProjectTechniqueActual\` DROP FOREIGN KEY \`FK_aaaee1c5fb44bef093ed78a0c32\``);
await queryRunner.query(`ALTER TABLE \`developmentProjectTechniquePlanned\` DROP FOREIGN KEY \`FK_7166cc94112552ea072a2cc6134\``);
await queryRunner.query(`DROP TABLE \`developmentProjectTechniqueActual\``);
await queryRunner.query(`DROP TABLE \`developmentProjectTechniquePlanned\``);
}
}

View file

@ -0,0 +1,26 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevelopmentScholarshipAddPlanType1712824449740 implements MigrationInterface {
name = 'UpdateTableDevelopmentScholarshipAddPlanType1712824449740'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`planType\` varchar(40) NULL COMMENT 'ในแผนฯ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`isNoUseBudget\` tinyint NOT NULL COMMENT 'ไม่ใช้งบประมาณ' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`governmentDate\` datetime NULL COMMENT 'กลับเข้ารับราชการตั้งแต่'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`isGraduated\` tinyint NOT NULL COMMENT 'สำเร็จการศึกษาตามที่หลักสูตรกำหนด' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`graduatedDate\` datetime NULL COMMENT 'ตั้งแต่'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`isNoGraduated\` tinyint NOT NULL COMMENT 'เสร็จสิ้นการศึกษาตามที่หลักสูตรกำหนดแล้วแต่ยังไม่สำเร็จการศึกษา' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`graduatedReason\` varchar(255) NULL COMMENT 'เนื่องจาก'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`graduatedReason\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`isNoGraduated\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`graduatedDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`isGraduated\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`governmentDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`isNoUseBudget\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`planType\``);
}
}

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevelopmentAddRoot1712904313381 implements MigrationInterface {
name = 'UpdateTableDevelopmentAddRoot1712904313381'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` ADD \`rootId\` varchar(255) NULL COMMENT 'id หน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`root\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`root\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`rootId\``);
}
}

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevelopmentAddRootshortname1712904744359 implements MigrationInterface {
name = 'UpdateTableDevelopmentAddRootshortname1712904744359'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` ADD \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่ิหน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`orgRevisionId\` varchar(255) NULL COMMENT 'id revision'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`orgRevisionId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`orgRootShortName\``);
}
}

View file

@ -0,0 +1,52 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevelopmentAddStrategyChild1712927871127 implements MigrationInterface {
name = 'UpdateTableDevelopmentAddStrategyChild1712927871127'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild1PlannedId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild1 เป้าหมายตามแผน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild2PlannedId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild2 เป้าหมายตามแผน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild3PlannedId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild3 เป้าหมายตามแผน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild4PlannedId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild4 เป้าหมายตามแผน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild5PlannedId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild5 เป้าหมายตามแผน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild1ActualId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild1 เป้าหมายตามจริง'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild2ActualId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild2 เป้าหมายตามจริง'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild3ActualId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild3 เป้าหมายตามจริง'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild4ActualId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild4 เป้าหมายตามจริง'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild5ActualId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild5 เป้าหมายตามจริง'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_10ff41d23b977cf8dce92e9b167\` FOREIGN KEY (\`strategyChild1PlannedId\`) REFERENCES \`strategyChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_593bc4c0cda43a2bee2928bda49\` FOREIGN KEY (\`strategyChild2PlannedId\`) REFERENCES \`strategyChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_231ce173640401d258c977aae79\` FOREIGN KEY (\`strategyChild3PlannedId\`) REFERENCES \`strategyChild3\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_44fb0c37a11d7ad9b8ca98aaa08\` FOREIGN KEY (\`strategyChild4PlannedId\`) REFERENCES \`strategyChild4\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_4cd86d57223a295e6de3c42cb61\` FOREIGN KEY (\`strategyChild5PlannedId\`) REFERENCES \`strategyChild5\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_a54d96cd5fda35d92815f7f65eb\` FOREIGN KEY (\`strategyChild1ActualId\`) REFERENCES \`strategyChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_8a8b6b92dfd3f78d012300524df\` FOREIGN KEY (\`strategyChild2ActualId\`) REFERENCES \`strategyChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_9ee4f1c6a2f2c86760da928f01a\` FOREIGN KEY (\`strategyChild3ActualId\`) REFERENCES \`strategyChild3\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_adf3d238b02f5806c9ed1e9b90b\` FOREIGN KEY (\`strategyChild4ActualId\`) REFERENCES \`strategyChild4\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_f078e198298457e517c8d90e337\` FOREIGN KEY (\`strategyChild5ActualId\`) REFERENCES \`strategyChild5\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_f078e198298457e517c8d90e337\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_adf3d238b02f5806c9ed1e9b90b\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_9ee4f1c6a2f2c86760da928f01a\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_8a8b6b92dfd3f78d012300524df\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_a54d96cd5fda35d92815f7f65eb\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_4cd86d57223a295e6de3c42cb61\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_44fb0c37a11d7ad9b8ca98aaa08\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_231ce173640401d258c977aae79\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_593bc4c0cda43a2bee2928bda49\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_10ff41d23b977cf8dce92e9b167\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild5ActualId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild4ActualId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild3ActualId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild2ActualId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild1ActualId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild5PlannedId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild4PlannedId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild3PlannedId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild2PlannedId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild1PlannedId\``);
}
}

View file

@ -0,0 +1,22 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevelopmentAddStrategyChild11712930900458 implements MigrationInterface {
name = 'UpdateTableDevelopmentAddStrategyChild11712930900458'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`rootId\` varchar(255) NULL COMMENT 'id หน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`root\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่ิหน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`orgRevisionId\` varchar(255) NULL COMMENT 'id revision'`);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`isDone\` tinyint NOT NULL COMMENT 'บันทึกลงทะเบียนประวัติ' DEFAULT 0`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`isDone\``);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`orgRevisionId\``);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`orgRootShortName\``);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`root\``);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`rootId\``);
}
}

View file

@ -0,0 +1,20 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevelopmentscholarAddRootid1713012352435 implements MigrationInterface {
name = 'UpdateTableDevelopmentscholarAddRootid1713012352435'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`rootId\` varchar(255) NULL COMMENT 'id หน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`root\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`orgRevisionId\` varchar(255) NULL COMMENT 'id revision'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`orgRevisionId\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`orgRootShortName\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`root\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`rootId\``);
}
}

View file

@ -0,0 +1,32 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevelopmentscholarDateToDatetime1713014657464 implements MigrationInterface {
name = 'UpdateTableDevelopmentscholarDateToDatetime1713014657464'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`bookNoDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`bookNoDate\` datetime NULL COMMENT 'ลงวันที่(หนังสือ)'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`bookApproveDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`bookApproveDate\` datetime NULL COMMENT 'หนังสืออนุมัติเมื่อวันที่'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`contractDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`contractDate\` datetime NULL COMMENT 'ลงวันที่(เลขที่สัญญา)'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`reportBackNoDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`reportBackNoDate\` datetime NULL COMMENT 'ลงวันที่(เลขที่หนังสือรายงานตัวกลับ)'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`reportBackDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`reportBackDate\` datetime NULL COMMENT 'รายงานตัวกลับวันที่'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`reportBackDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`reportBackDate\` date NULL COMMENT 'รายงานตัวกลับวันที่'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`reportBackNoDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`reportBackNoDate\` date NULL COMMENT 'ลงวันที่(เลขที่หนังสือรายงานตัวกลับ)'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`contractDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`contractDate\` date NULL COMMENT 'ลงวันที่(เลขที่สัญญา)'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`bookApproveDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`bookApproveDate\` date NULL COMMENT 'หนังสืออนุมัติเมื่อวันที่'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`bookNoDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`bookNoDate\` date NULL COMMENT 'ลงวันที่(หนังสือ)'`);
}
}

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevelopmentHistoryAddProfileId1713163199894 implements MigrationInterface {
name = 'UpdateTableDevelopmentHistoryAddProfileId1713163199894'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`profileId\` varchar(40) NULL COMMENT 'id profile'`);
await queryRunner.query(`ALTER TABLE \`development\` CHANGE \`orgRootShortName\` \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` CHANGE \`orgRootShortName\` \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่ิหน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`profileId\``);
}
}

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevelopmentHistoryAddTrainingDays1713179439957 implements MigrationInterface {
name = 'UpdateTableDevelopmentHistoryAddTrainingDays1713179439957'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`trainingDays\` varchar(255) NULL COMMENT 'จำนวนวันที่อบรม'`);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` CHANGE \`orgRootShortName\` \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` CHANGE \`orgRootShortName\` \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่ิหน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`trainingDays\``);
}
}

View file

@ -0,0 +1,22 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevAddGovernmentEndDate1713332483208 implements MigrationInterface {
name = 'UpdateTableDevAddGovernmentEndDate1713332483208'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`bookNumber\` varchar(255) NULL COMMENT 'เลขที่หนังสือรายงานตัวกลับเข้าปฏิบัติราชการ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`bookDate\` datetime NULL COMMENT ' หนังสือรายงานตัวกลับเข้าปฏิบัติราชการลงวันที่'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`governmentEndDate\` datetime NULL COMMENT 'วันสิ้นสุดภาระผูกพัน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` CHANGE \`governmentDate\` \`governmentDate\` datetime NULL COMMENT 'วันที่กลับเข้าปฏิบัติราชการ'`);
await queryRunner.query(`ALTER TABLE \`strategyChild5\` CHANGE \`strategyChild5Name\` \`strategyChild5Name\` varchar(255) NULL COMMENT 'กลยุทธ์ที่/เป้าประสงค์ที่'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`strategyChild5\` CHANGE \`strategyChild5Name\` \`strategyChild5Name\` varchar(255) NULL COMMENT 'กลยุทธ์ที่'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` CHANGE \`governmentDate\` \`governmentDate\` datetime NULL COMMENT 'กลับเข้ารับราชการตั้งแต่'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`governmentEndDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`bookDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`bookNumber\``);
}
}

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevAddGovernmentEndDate11713334672151 implements MigrationInterface {
name = 'UpdateTableDevAddGovernmentEndDate11713334672151'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`isNoGraduated\``);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`isNoGraduated\` tinyint NOT NULL COMMENT 'เสร็จสิ้นการศึกษาตามที่หลักสูตรกำหนดแล้วแต่ยังไม่สำเร็จการศึกษา' DEFAULT '0'`);
}
}

View file

@ -0,0 +1,18 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevAddGovernmentEndDate21713338710965 implements MigrationInterface {
name = 'UpdateTableDevAddGovernmentEndDate21713338710965'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectModal\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectModalPlanned\` int NULL COMMENT 'จำนวน(รุ่น)ตามแผน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectModalActual\` int NULL COMMENT 'จำนวน(รุ่น)ตามจริง'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectModalActual\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectModalPlanned\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectModal\` int NULL COMMENT 'จำนวน(รุ่น)'`);
}
}

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevhisAddDateStart1713340723367 implements MigrationInterface {
name = 'UpdateTableDevhisAddDateStart1713340723367'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`dateStart\` datetime NULL COMMENT 'วันที่เริ่มต้น'`);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`dateEnd\` datetime NULL COMMENT 'วันที่สิ้นสุด'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`dateEnd\``);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`dateStart\``);
}
}

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevhisAddType1713341677475 implements MigrationInterface {
name = 'UpdateTableDevhisAddType1713341677475'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`plannedGoal\` ADD \`type\` varchar(255) NULL COMMENT 'ประเภท(กลุ่มอาชีพ คุณสมบัติ)'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`plannedGoal\` DROP COLUMN \`type\``);
}
}

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevhisAddOrg1713347839774 implements MigrationInterface {
name = 'UpdateTableDevhisAddOrg1713347839774'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`org\` varchar(255) NULL COMMENT 'ชื่อหน่วยงานที่สังกัด'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`org\` varchar(255) NULL COMMENT 'ชื่อหน่วยงานที่สังกัด'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`org\``);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`org\``);
}
}

View file

@ -0,0 +1,40 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevAddChild11713366798329 implements MigrationInterface {
name = 'UpdateTableDevAddChild11713366798329'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`orgRootShortName\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`rootShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child1Id\` varchar(255) NULL COMMENT 'id หน่วยงาน child1'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child1\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน child1'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child1ShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน child1'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child2Id\` varchar(255) NULL COMMENT 'id หน่วยงาน child2'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child2\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน child2'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child2ShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน child2'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child3Id\` varchar(255) NULL COMMENT 'id หน่วยงาน child3'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child3\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน child3'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child3ShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน child3'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child4Id\` varchar(255) NULL COMMENT 'id หน่วยงาน child4'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child4\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน child4'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child4ShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน child4'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child4ShortName\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child4\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child4Id\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child3ShortName\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child3\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child3Id\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child2ShortName\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child2\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child2Id\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child1ShortName\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child1\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child1Id\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`rootShortName\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน'`);
}
}

View file

@ -0,0 +1,22 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevscholarAddGuarantorOrg1713431125506 implements MigrationInterface {
name = 'UpdateTableDevscholarAddGuarantorOrg1713431125506'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`guarantorRootId\` varchar(255) NULL COMMENT 'id หน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`guarantorRoot\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`guarantorOrg\` varchar(255) NULL COMMENT 'ชื่อหน่วยงานที่สังกัด'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`guarantorOrgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`guarantorOrgRevisionId\` varchar(255) NULL COMMENT 'id revision'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`guarantorOrgRevisionId\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`guarantorOrgRootShortName\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`guarantorOrg\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`guarantorRoot\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`guarantorRootId\``);
}
}

View file

@ -0,0 +1,20 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevReasonText1716270845115 implements MigrationInterface {
name = 'UpdateTableDevReasonText1716270845115'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reason\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`reason\` text NULL COMMENT 'หลักการและเหตุผล'`);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`objective\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`objective\` text NULL COMMENT 'วัตถุประสงค์'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`objective\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`objective\` varchar(255) NULL COMMENT 'วัตถุประสงค์'`);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reason\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`reason\` varchar(255) NULL COMMENT 'หลักการและเหตุผล'`);
}
}

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTablePortfolio1719477296897 implements MigrationInterface {
name = 'AddTablePortfolio1719477296897'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE \`portfolio\` (\`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', \`name\` varchar(255) NULL COMMENT 'ชื่อเอกสาร/ผลงาน', \`detail\` varchar(255) NULL COMMENT 'รายละเอียดเอกสาร/ผลงาน', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP TABLE \`portfolio\``);
}
}

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateField1720165194013 implements MigrationInterface {
name = 'UpdateField1720165194013'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`portfolio\` DROP COLUMN \`detail\``);
await queryRunner.query(`ALTER TABLE \`portfolio\` ADD \`detail\` longtext NULL COMMENT 'รายละเอียดเอกสาร/ผลงาน'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`portfolio\` DROP COLUMN \`detail\``);
await queryRunner.query(`ALTER TABLE \`portfolio\` ADD \`detail\` varchar(255) NULL COMMENT 'รายละเอียดเอกสาร/ผลงาน'`);
}
}

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableDev11720174912913 implements MigrationInterface {
name = 'AddTableDev11720174912913'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentProjectTechniquePlanned\` ADD \`detail\` varchar(255) NULL COMMENT 'รายละเอียด'`);
await queryRunner.query(`ALTER TABLE \`developmentProjectTechniqueActual\` ADD \`detail\` varchar(255) NULL COMMENT 'รายละเอียด'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentProjectTechniqueActual\` DROP COLUMN \`detail\``);
await queryRunner.query(`ALTER TABLE \`developmentProjectTechniquePlanned\` DROP COLUMN \`detail\``);
}
}

View file

@ -0,0 +1,20 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableDev21720175549705 implements MigrationInterface {
name = 'AddTableDev21720175549705'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentProjectTechniquePlanned\` DROP COLUMN \`detail\``);
await queryRunner.query(`ALTER TABLE \`developmentProjectTechniqueActual\` DROP COLUMN \`detail\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`reasonPlanned\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ แผน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`reasonActual\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ จริง'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reasonActual\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reasonPlanned\``);
await queryRunner.query(`ALTER TABLE \`developmentProjectTechniqueActual\` ADD \`detail\` varchar(255) NULL COMMENT 'รายละเอียด'`);
await queryRunner.query(`ALTER TABLE \`developmentProjectTechniquePlanned\` ADD \`detail\` varchar(255) NULL COMMENT 'รายละเอียด'`);
}
}

View file

@ -0,0 +1,28 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableDevAddReasonActual701721053734191 implements MigrationInterface {
name = 'AddTableDevAddReasonActual701721053734191'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reasonPlanned\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reasonActual\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`reasonPlanned70\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 70 แผน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`reasonPlanned20\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 20 แผน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`reasonPlanned10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 แผน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`reasonActual70\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 70 จริง'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`reasonActual20\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 20 จริง'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`reasonActual10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 จริง'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reasonActual10\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reasonActual20\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reasonActual70\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reasonPlanned10\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reasonPlanned20\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reasonPlanned70\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`reasonActual\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ จริง'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`reasonPlanned\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ แผน'`);
}
}

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class Update300620256041750083465733 implements MigrationInterface {
name = 'Update300620256041750083465733'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`rootDnaId\` varchar(255) NULL COMMENT 'id dna หน่วยงาน'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`rootDnaId\``);
}
}

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class Update300620256051750083913468 implements MigrationInterface {
name = 'Update300620256051750083913468'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`guarantorRootDnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`guarantorRootDnaId\``);
}
}

View file

@ -28,6 +28,18 @@
"tags": [
{
"name": "Test", "description": "สำหรับทดสอบ"
},
{
"name": "Development", "description": "ชื่อโครงการ/กิจกรรม/หลักสูตร"
},
{
"name": "DevelopmentOfficerHistory", "description": "ประวัติการฝึกอบรม/ดูงาน ขรก."
},
{
"name": "DevelopmentEmployeeHistory", "description": "ประวัติการฝึกอบรม/ดูงานลูกจ้าง."
},
{
"name": "DevelopmentScholarship", "description": "ทุนการศึกษา/ฝึกอบรม"
}
]
},