From bd002135961d068e9877b6644f0ad49f82459d99 Mon Sep 17 00:00:00 2001 From: moss <> Date: Tue, 25 Mar 2025 10:32:06 +0700 Subject: [PATCH 01/32] =?UTF-8?q?sort=20=E0=B8=A2=E0=B8=B8=E0=B8=97?= =?UTF-8?q?=E0=B8=A8=E0=B8=B2=E0=B8=AA=E0=B8=95=E0=B8=A3=E0=B9=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/StrategyController.ts | 33 ++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/controllers/StrategyController.ts b/src/controllers/StrategyController.ts index ce1cbd2..a00f3cf 100644 --- a/src/controllers/StrategyController.ts +++ b/src/controllers/StrategyController.ts @@ -43,7 +43,16 @@ export class StrategyController extends Controller { "strategyChild2s.strategyChild3s.strategyChild4s", "strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s", ], - order: { createdAt: "ASC" }, + order: { + createdAt: "ASC", + strategyChild2s: { + createdAt: "ASC", + strategyChild3s: { + createdAt: "ASC", + strategyChild4s: { createdAt: "ASC", strategyChild5s: { createdAt: "ASC" } }, + }, + }, + }, }); const formattedData = listStrategyChild1.map((item) => ({ @@ -100,7 +109,16 @@ export class StrategyController extends Controller { "strategyChild2s.strategyChild3s.strategyChild4s", "strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s", ], - order: { createdAt: "ASC" }, + order: { + createdAt: "ASC", + strategyChild2s: { + createdAt: "ASC", + strategyChild3s: { + createdAt: "ASC", + strategyChild4s: { createdAt: "ASC", strategyChild5s: { createdAt: "ASC" } }, + }, + }, + }, }); // if (!listStrategyChild1 || listStrategyChild1.length === 0) { @@ -151,7 +169,16 @@ export class StrategyController extends Controller { "strategyChild2s.strategyChild3s.strategyChild4s", "strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s", ], - order: { createdAt: "ASC" }, + order: { + createdAt: "ASC", + strategyChild2s: { + createdAt: "ASC", + strategyChild3s: { + createdAt: "ASC", + strategyChild4s: { createdAt: "ASC", strategyChild5s: { createdAt: "ASC" } }, + }, + }, + }, }); // if (!listStrategyChild1 || listStrategyChild1.length === 0) { From 00f76bbd2b08eea89938d583603d22690fd04b7a Mon Sep 17 00:00:00 2001 From: moss <> Date: Thu, 27 Mar 2025 14:46:42 +0700 Subject: [PATCH 02/32] add sort --- src/controllers/StrategyController.ts | 142 ++++++++++++++++-- src/entities/StrategyChild1.ts | 7 + src/entities/StrategyChild2.ts | 7 + src/entities/StrategyChild3.ts | 7 + src/entities/StrategyChild4.ts | 7 + src/entities/StrategyChild5.ts | 7 + ...429-update_developmentHis_add_isDoneIDP.ts | 14 -- ...update_development_add_isReasonActual70.ts | 24 --- ...update_development_add_isReasonActual10.ts | 20 --- ...11015155-update_delete_dev_provincename.ts | 22 --- .../1738201344610-Updatedevadddna.ts | 28 ---- src/migration/1739444714910-updateView.ts | 23 --- ...1739446719623-update_viewDevScholarship.ts | 23 --- .../1743061489009-update_strategyadddorder.ts | 22 +++ 14 files changed, 187 insertions(+), 166 deletions(-) delete mode 100644 src/migration/1727719189429-update_developmentHis_add_isDoneIDP.ts delete mode 100644 src/migration/1727753251629-update_development_add_isReasonActual70.ts delete mode 100644 src/migration/1727755044851-update_development_add_isReasonActual10.ts delete mode 100644 src/migration/1737111015155-update_delete_dev_provincename.ts delete mode 100644 src/migration/1738201344610-Updatedevadddna.ts delete mode 100644 src/migration/1739444714910-updateView.ts delete mode 100644 src/migration/1739446719623-update_viewDevScholarship.ts create mode 100644 src/migration/1743061489009-update_strategyadddorder.ts diff --git a/src/controllers/StrategyController.ts b/src/controllers/StrategyController.ts index a00f3cf..5861879 100644 --- a/src/controllers/StrategyController.ts +++ b/src/controllers/StrategyController.ts @@ -6,6 +6,7 @@ import { Patch, Path, Post, + Put, Request, Route, Security, @@ -44,12 +45,12 @@ export class StrategyController extends Controller { "strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s", ], order: { - createdAt: "ASC", + order: "ASC", strategyChild2s: { - createdAt: "ASC", + order: "ASC", strategyChild3s: { - createdAt: "ASC", - strategyChild4s: { createdAt: "ASC", strategyChild5s: { createdAt: "ASC" } }, + order: "ASC", + strategyChild4s: { order: "ASC", strategyChild5s: { order: "ASC" } }, }, }, }, @@ -59,25 +60,30 @@ export class StrategyController extends Controller { 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, })) : [], })) @@ -110,12 +116,12 @@ export class StrategyController extends Controller { "strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s", ], order: { - createdAt: "ASC", + order: "ASC", strategyChild2s: { - createdAt: "ASC", + order: "ASC", strategyChild3s: { - createdAt: "ASC", - strategyChild4s: { createdAt: "ASC", strategyChild5s: { createdAt: "ASC" } }, + order: "ASC", + strategyChild4s: { order: "ASC", strategyChild5s: { order: "ASC" } }, }, }, }, @@ -129,25 +135,30 @@ export class StrategyController extends Controller { 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, })) : [], })) @@ -170,12 +181,12 @@ export class StrategyController extends Controller { "strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s", ], order: { - createdAt: "ASC", + order: "ASC", strategyChild2s: { - createdAt: "ASC", + order: "ASC", strategyChild3s: { - createdAt: "ASC", - strategyChild4s: { createdAt: "ASC", strategyChild5s: { createdAt: "ASC" } }, + order: "ASC", + strategyChild4s: { order: "ASC", strategyChild5s: { order: "ASC" } }, }, }, }, @@ -189,25 +200,30 @@ export class StrategyController extends Controller { 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, })) : [], })) @@ -237,22 +253,30 @@ export class StrategyController extends Controller { switch (body.levelnode) { case 0: + const ckOrder = await this.strategy1Repo.findOne({ + 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, "ไม่พบข้อมูลยุทธศาสตร์"); } @@ -263,13 +287,16 @@ export class StrategyController extends Controller { 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, "ไม่พบข้อมูลยุทธศาสตร์"); } @@ -280,14 +307,17 @@ export class StrategyController extends Controller { 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, "ไม่พบข้อมูลยุทธศาสตร์"); } @@ -298,15 +328,18 @@ export class StrategyController extends Controller { 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, "ไม่พบข้อมูลยุทธศาสตร์"); } @@ -621,4 +654,89 @@ export class StrategyController extends Controller { 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, + level: requestBody.strategyId.indexOf(data.id) + 1, + })); + await this.strategy1Repo.save(sortLevel); + return new HttpSuccess(sortLevel); + } + case 2: { + const data = await this.strategy2Repo.find({ + where: { id: requestBody.id ?? "" }, + }); + if (data == null) { + throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy2."); + } + const sortLevel = data.map((data) => ({ + ...data, + level: requestBody.strategyId.indexOf(data.id) + 1, + })); + await this.strategy2Repo.save(sortLevel); + return new HttpSuccess(sortLevel); + } + case 3: { + const data = await this.strategy3Repo.find({ + where: { id: requestBody.id ?? "" }, + }); + if (data == null) { + throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy3."); + } + const sortLevel = data.map((data) => ({ + ...data, + level: requestBody.strategyId.indexOf(data.id) + 1, + })); + await this.strategy3Repo.save(sortLevel); + return new HttpSuccess(sortLevel); + } + case 4: { + const data = await this.strategy4Repo.find({ + where: { id: requestBody.id ?? "" }, + }); + if (data == null) { + throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy4."); + } + const sortLevel = data.map((data) => ({ + ...data, + level: requestBody.strategyId.indexOf(data.id) + 1, + })); + await this.strategy4Repo.save(sortLevel); + return new HttpSuccess(sortLevel); + } + case 5: { + const data = await this.strategy5Repo.find({ + where: { id: requestBody.id ?? "" }, + }); + if (data == null) { + throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy5."); + } + const sortLevel = data.map((data) => ({ + ...data, + level: 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); + } + } } diff --git a/src/entities/StrategyChild1.ts b/src/entities/StrategyChild1.ts index 05c56ea..8bc9803 100644 --- a/src/entities/StrategyChild1.ts +++ b/src/entities/StrategyChild1.ts @@ -16,6 +16,13 @@ export class StrategyChild1 extends EntityBase { }) strategyChild1Name: string; + @Column({ + nullable: true, + comment: "ลำดับความสำคัญ", + default: null, + }) + order: number; + @OneToMany(() => StrategyChild2, (strategyChild2) => strategyChild2.strategyChild1) strategyChild2s: StrategyChild2[]; diff --git a/src/entities/StrategyChild2.ts b/src/entities/StrategyChild2.ts index 9425e59..0f57eef 100644 --- a/src/entities/StrategyChild2.ts +++ b/src/entities/StrategyChild2.ts @@ -22,6 +22,13 @@ export class StrategyChild2 extends EntityBase { }) strategyChild1Id: string; + @Column({ + nullable: true, + comment: "ลำดับความสำคัญ", + default: null, + }) + order: number; + @ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild2s) @JoinColumn({ name: "strategyChild1Id" }) strategyChild1: StrategyChild1; diff --git a/src/entities/StrategyChild3.ts b/src/entities/StrategyChild3.ts index 9698d0c..d8c5ba7 100644 --- a/src/entities/StrategyChild3.ts +++ b/src/entities/StrategyChild3.ts @@ -28,6 +28,13 @@ export class StrategyChild3 extends EntityBase { }) strategyChild2Id: string; + @Column({ + nullable: true, + comment: "ลำดับความสำคัญ", + default: null, + }) + order: number; + @ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild3s) @JoinColumn({ name: "strategyChild1Id" }) strategyChild1: StrategyChild1; diff --git a/src/entities/StrategyChild4.ts b/src/entities/StrategyChild4.ts index 4382a0c..6c5d58e 100644 --- a/src/entities/StrategyChild4.ts +++ b/src/entities/StrategyChild4.ts @@ -34,6 +34,13 @@ export class StrategyChild4 extends EntityBase { }) strategyChild3Id: string; + @Column({ + nullable: true, + comment: "ลำดับความสำคัญ", + default: null, + }) + order: number; + @ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild4s) @JoinColumn({ name: "strategyChild1Id" }) strategyChild1: StrategyChild1; diff --git a/src/entities/StrategyChild5.ts b/src/entities/StrategyChild5.ts index 7282210..9d3f413 100644 --- a/src/entities/StrategyChild5.ts +++ b/src/entities/StrategyChild5.ts @@ -40,6 +40,13 @@ export class StrategyChild5 extends EntityBase { }) strategyChild4Id: string; + @Column({ + nullable: true, + comment: "ลำดับความสำคัญ", + default: null, + }) + order: number; + @ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild5s) @JoinColumn({ name: "strategyChild1Id" }) strategyChild1: StrategyChild1; diff --git a/src/migration/1727719189429-update_developmentHis_add_isDoneIDP.ts b/src/migration/1727719189429-update_developmentHis_add_isDoneIDP.ts deleted file mode 100644 index c577bb8..0000000 --- a/src/migration/1727719189429-update_developmentHis_add_isDoneIDP.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateDevelopmentHisAddIsDoneIDP1727719189429 implements MigrationInterface { - name = 'UpdateDevelopmentHisAddIsDoneIDP1727719189429' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`isDoneIDP\` tinyint NOT NULL COMMENT 'บันทึก IDP ที่ทะเบียนประวัติ' DEFAULT 0`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`isDoneIDP\``); - } - -} diff --git a/src/migration/1727753251629-update_development_add_isReasonActual70.ts b/src/migration/1727753251629-update_development_add_isReasonActual70.ts deleted file mode 100644 index 32c8f84..0000000 --- a/src/migration/1727753251629-update_development_add_isReasonActual70.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateDevelopmentAddIsReasonActual701727753251629 implements MigrationInterface { - name = 'UpdateDevelopmentAddIsReasonActual701727753251629' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonPlanned70\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 70 แผน' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonPlanned20\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 20 แผน' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonPlanned10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 แผน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonActual70\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 70 จริง' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonActual20\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 20 จริง' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonActual10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 จริง'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonActual10\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonActual20\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonActual70\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonPlanned10\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonPlanned20\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonPlanned70\``); - } - -} diff --git a/src/migration/1727755044851-update_development_add_isReasonActual10.ts b/src/migration/1727755044851-update_development_add_isReasonActual10.ts deleted file mode 100644 index a5a0c33..0000000 --- a/src/migration/1727755044851-update_development_add_isReasonActual10.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateDevelopmentAddIsReasonActual101727755044851 implements MigrationInterface { - name = 'UpdateDevelopmentAddIsReasonActual101727755044851' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonPlanned10\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonPlanned10\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 10 แผน' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonActual10\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonActual10\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 10 จริง' DEFAULT 0`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonActual10\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonActual10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 จริง'`); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonPlanned10\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonPlanned10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 แผน'`); - } - -} diff --git a/src/migration/1737111015155-update_delete_dev_provincename.ts b/src/migration/1737111015155-update_delete_dev_provincename.ts deleted file mode 100644 index 9f0b4e5..0000000 --- a/src/migration/1737111015155-update_delete_dev_provincename.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateDeleteDevProvincename1737111015155 implements MigrationInterface { - name = 'UpdateDeleteDevProvincename1737111015155' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentAddress\` DROP FOREIGN KEY \`FK_e2721b3f440256b56ce83a04fb2\``); - await queryRunner.query(`ALTER TABLE \`developmentOther\` DROP FOREIGN KEY \`FK_47bbbecaea9b7b31d2536054656\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_bdafbb824b88c3bdb73adf7f220\``); - await queryRunner.query(`ALTER TABLE \`developmentAddress\` ADD \`provinceName\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม'`); - await queryRunner.query(`ALTER TABLE \`developmentOther\` ADD \`provinceActualName\` varchar(255) NULL COMMENT 'จังหวัด(ข้อมูลวิชาการ)'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentOther\` DROP COLUMN \`provinceActualName\``); - await queryRunner.query(`ALTER TABLE \`developmentAddress\` DROP COLUMN \`provinceName\``); - 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 \`developmentOther\` ADD CONSTRAINT \`FK_47bbbecaea9b7b31d2536054656\` FOREIGN KEY (\`provinceActualId\`) REFERENCES \`province\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`developmentAddress\` ADD CONSTRAINT \`FK_e2721b3f440256b56ce83a04fb2\` FOREIGN KEY (\`provinceId\`) REFERENCES \`province\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - -} diff --git a/src/migration/1738201344610-Updatedevadddna.ts b/src/migration/1738201344610-Updatedevadddna.ts deleted file mode 100644 index 4b3ebc1..0000000 --- a/src/migration/1738201344610-Updatedevadddna.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class Updatedevadddna1738201344610 implements MigrationInterface { - name = 'Updatedevadddna1738201344610' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`DROP INDEX \`FK_e2721b3f440256b56ce83a04fb2\` ON \`developmentAddress\``); - await queryRunner.query(`DROP INDEX \`FK_47bbbecaea9b7b31d2536054656\` ON \`developmentOther\``); - await queryRunner.query(`DROP INDEX \`FK_bdafbb824b88c3bdb73adf7f220\` ON \`development\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`rootDnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`child1DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child1'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`child2DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child2'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`child3DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child3'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`child4DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child4'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child4DnaId\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child3DnaId\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child2DnaId\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child1DnaId\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`rootDnaId\``); - await queryRunner.query(`CREATE INDEX \`FK_bdafbb824b88c3bdb73adf7f220\` ON \`development\` (\`provinceActualId\`)`); - await queryRunner.query(`CREATE INDEX \`FK_47bbbecaea9b7b31d2536054656\` ON \`developmentOther\` (\`provinceActualId\`)`); - await queryRunner.query(`CREATE INDEX \`FK_e2721b3f440256b56ce83a04fb2\` ON \`developmentAddress\` (\`provinceId\`)`); - } - -} diff --git a/src/migration/1739444714910-updateView.ts b/src/migration/1739444714910-updateView.ts deleted file mode 100644 index ab12b2e..0000000 --- a/src/migration/1739444714910-updateView.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateView1739444714910 implements MigrationInterface { - name = 'UpdateView1739444714910' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE VIEW \`view_dev_scholarship\` AS 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\` - `); - await queryRunner.query(`INSERT INTO \`bma_ehr_development_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_development_demo","VIEW","view_dev_scholarship","SELECT MAX(`rootId`) AS rootId, \n MAX(`root`) AS root,`degreeLevel`,\n COUNT(*) AS numberOfRecords, \n COUNT(DISTINCT `scholarshipType`) AS numberOfScholarshipTypes,\n SUM(`budgetApprove`) AS totalBudgetApprove\n FROM `developmentScholarship`\n GROUP BY `rootId`,`degreeLevel`"]); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`DELETE FROM \`bma_ehr_development_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_dev_scholarship","bma_ehr_development_demo"]); - await queryRunner.query(`DROP VIEW \`view_dev_scholarship\``); - } - -} diff --git a/src/migration/1739446719623-update_viewDevScholarship.ts b/src/migration/1739446719623-update_viewDevScholarship.ts deleted file mode 100644 index 9a1acbc..0000000 --- a/src/migration/1739446719623-update_viewDevScholarship.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateViewDevScholarship1739446719623 implements MigrationInterface { - name = 'UpdateViewDevScholarship1739446719623' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE VIEW \`view_dev_scholarship\` AS 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\` - `); - await queryRunner.query(`INSERT INTO \`bma_ehr_development_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_development_demo","VIEW","view_dev_scholarship","SELECT MAX(`rootId`) AS rootId, \n MAX(`root`) AS root,`degreeLevel`,\n COUNT(*) AS numberOfRecords, \n COUNT(DISTINCT `scholarshipType`) AS numberOfScholarshipTypes,\n SUM(`budgetApprove`) AS totalBudgetApprove\n FROM `developmentScholarship`\n GROUP BY `rootId`,`degreeLevel`"]); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`DELETE FROM \`bma_ehr_development_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_dev_scholarship","bma_ehr_development_demo"]); - await queryRunner.query(`DROP VIEW \`view_dev_scholarship\``); - } - -} diff --git a/src/migration/1743061489009-update_strategyadddorder.ts b/src/migration/1743061489009-update_strategyadddorder.ts new file mode 100644 index 0000000..c6c6e16 --- /dev/null +++ b/src/migration/1743061489009-update_strategyadddorder.ts @@ -0,0 +1,22 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateStrategyadddorder1743061489009 implements MigrationInterface { + name = 'UpdateStrategyadddorder1743061489009' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`strategyChild4\` ADD \`order\` int NULL COMMENT 'ลำดับความสำคัญ'`); + await queryRunner.query(`ALTER TABLE \`strategyChild3\` ADD \`order\` int NULL COMMENT 'ลำดับความสำคัญ'`); + await queryRunner.query(`ALTER TABLE \`strategyChild2\` ADD \`order\` int NULL COMMENT 'ลำดับความสำคัญ'`); + await queryRunner.query(`ALTER TABLE \`strategyChild1\` ADD \`order\` int NULL COMMENT 'ลำดับความสำคัญ'`); + await queryRunner.query(`ALTER TABLE \`strategyChild5\` ADD \`order\` int NULL COMMENT 'ลำดับความสำคัญ'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`strategyChild5\` DROP COLUMN \`order\``); + await queryRunner.query(`ALTER TABLE \`strategyChild1\` DROP COLUMN \`order\``); + await queryRunner.query(`ALTER TABLE \`strategyChild2\` DROP COLUMN \`order\``); + await queryRunner.query(`ALTER TABLE \`strategyChild3\` DROP COLUMN \`order\``); + await queryRunner.query(`ALTER TABLE \`strategyChild4\` DROP COLUMN \`order\``); + } + +} From c9845b0256846d739bb7cea044710526fca2d60b Mon Sep 17 00:00:00 2001 From: moss <> Date: Fri, 28 Mar 2025 15:10:26 +0700 Subject: [PATCH 03/32] sort data --- src/controllers/StrategyController.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/controllers/StrategyController.ts b/src/controllers/StrategyController.ts index 5861879..f9d7be8 100644 --- a/src/controllers/StrategyController.ts +++ b/src/controllers/StrategyController.ts @@ -674,7 +674,7 @@ export class StrategyController extends Controller { } const sortLevel = data.map((data) => ({ ...data, - level: requestBody.strategyId.indexOf(data.id) + 1, + order: requestBody.strategyId.indexOf(data.id) + 1, })); await this.strategy1Repo.save(sortLevel); return new HttpSuccess(sortLevel); @@ -688,7 +688,7 @@ export class StrategyController extends Controller { } const sortLevel = data.map((data) => ({ ...data, - level: requestBody.strategyId.indexOf(data.id) + 1, + order: requestBody.strategyId.indexOf(data.id) + 1, })); await this.strategy2Repo.save(sortLevel); return new HttpSuccess(sortLevel); @@ -702,7 +702,7 @@ export class StrategyController extends Controller { } const sortLevel = data.map((data) => ({ ...data, - level: requestBody.strategyId.indexOf(data.id) + 1, + order: requestBody.strategyId.indexOf(data.id) + 1, })); await this.strategy3Repo.save(sortLevel); return new HttpSuccess(sortLevel); @@ -716,7 +716,7 @@ export class StrategyController extends Controller { } const sortLevel = data.map((data) => ({ ...data, - level: requestBody.strategyId.indexOf(data.id) + 1, + order: requestBody.strategyId.indexOf(data.id) + 1, })); await this.strategy4Repo.save(sortLevel); return new HttpSuccess(sortLevel); @@ -730,7 +730,7 @@ export class StrategyController extends Controller { } const sortLevel = data.map((data) => ({ ...data, - level: requestBody.strategyId.indexOf(data.id) + 1, + order: requestBody.strategyId.indexOf(data.id) + 1, })); await this.strategy5Repo.save(sortLevel); return new HttpSuccess(sortLevel); From 28df293eef5b5b669d44897c1b391b7bba7b68f1 Mon Sep 17 00:00:00 2001 From: moss <> Date: Fri, 28 Mar 2025 21:44:55 +0700 Subject: [PATCH 04/32] sort --- .github/workflows/release.yaml | 73 +++++++++++++-------------- src/controllers/StrategyController.ts | 8 +-- 2 files changed, 40 insertions(+), 41 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2f29d54..6916881 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -67,41 +67,40 @@ jobs: docker compose pull docker compose up -d echo "${{ steps.gen_ver.outputs.image_ver }}"> success - - name: Notify Discord Success - if: success() - 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() - 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 }} + # - name: Notify Discord Success + # if: success() + # 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() + # 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 }} diff --git a/src/controllers/StrategyController.ts b/src/controllers/StrategyController.ts index f9d7be8..bd29960 100644 --- a/src/controllers/StrategyController.ts +++ b/src/controllers/StrategyController.ts @@ -681,7 +681,7 @@ export class StrategyController extends Controller { } case 2: { const data = await this.strategy2Repo.find({ - where: { id: requestBody.id ?? "" }, + where: { strategyChild1Id: requestBody.id ?? "" }, }); if (data == null) { throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy2."); @@ -695,7 +695,7 @@ export class StrategyController extends Controller { } case 3: { const data = await this.strategy3Repo.find({ - where: { id: requestBody.id ?? "" }, + where: { strategyChild2Id: requestBody.id ?? "" }, }); if (data == null) { throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy3."); @@ -709,7 +709,7 @@ export class StrategyController extends Controller { } case 4: { const data = await this.strategy4Repo.find({ - where: { id: requestBody.id ?? "" }, + where: { strategyChild3Id: requestBody.id ?? "" }, }); if (data == null) { throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy4."); @@ -723,7 +723,7 @@ export class StrategyController extends Controller { } case 5: { const data = await this.strategy5Repo.find({ - where: { id: requestBody.id ?? "" }, + where: { strategyChild4Id: requestBody.id ?? "" }, }); if (data == null) { throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy5."); From 9f41422b1bf6d602ffda9c7c7637ab67d1017d3b Mon Sep 17 00:00:00 2001 From: moss <> Date: Tue, 1 Apr 2025 00:38:15 +0700 Subject: [PATCH 05/32] check type object log --- src/interfaces/utils.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/interfaces/utils.ts b/src/interfaces/utils.ts index 30035f0..c667f54 100644 --- a/src/interfaces/utils.ts +++ b/src/interfaces/utils.ts @@ -19,10 +19,20 @@ export type LogSequence = { }; export function setLogDataDiff(req: RequestWithUser, data: DataDiff) { - req.app.locals.logData.dataDiff = { - before: JSON.stringify(data.before), - after: JSON.stringify(data.after), - }; + // 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) { From c6668cbc27594b2ae3af25f00c9e0ecc1253ff1f Mon Sep 17 00:00:00 2001 From: moss <> Date: Tue, 1 Apr 2025 01:34:54 +0700 Subject: [PATCH 06/32] on noti --- .github/workflows/release.yaml | 72 +++++++++++++++++----------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6916881..0d19c5a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -67,40 +67,40 @@ jobs: docker compose pull docker compose up -d echo "${{ steps.gen_ver.outputs.image_ver }}"> success - # - name: Notify Discord Success - # if: success() - # 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 Success + if: success() + 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() - # 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 }} + - name: Notify Discord Failure + if: failure() + 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 }} From 316334021591b3540a5c077a7665b07ee4770ab4 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 10 Apr 2025 11:11:53 +0700 Subject: [PATCH 07/32] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=9A?= =?UTF-8?q?=E0=B8=B1=E0=B8=84=E0=B8=A3=E0=B8=B0=E0=B8=9A=E0=B8=9A=E0=B8=9E?= =?UTF-8?q?=E0=B8=B1=E0=B8=92=E0=B8=99=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/DevelopmentController.ts | 54 ++++++++++++++++--- .../DevelopmentHistoryController.ts | 1 + src/controllers/ReportController.ts | 10 ++++ 3 files changed, 59 insertions(+), 6 deletions(-) diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index 2cd5f30..95d2ae4 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -2539,9 +2539,51 @@ export class DevelopmentController extends Controller { where: { developmentId: id, isDoneIDP: false }, relations: ["development", "development.developmentProjectTechniqueActuals"], }); + + let isDevelopment70: boolean = false + const dev70Lists = [ + "on_the_job_training", + "job_project_assignment", + "job_shadowing", + "job_enlargement", + "internal_trainer", + "rotation", + "activity", + "site_visit", + "benchmarking", + "problem_solving", + "team_working", + "other1" + ]; + let isDevelopment20: boolean = false + const dev20Lists = [ + "coaching", + "mentoring", + "team_meeting", + "consulting", + "feedback", + "other2" + ]; + let isDevelopment10: boolean = false + const dev10Lists = [ + "self_learning", + "classroom_training", + "in_house_training", + "public_training", + "e_training", + "meeting", + "seminar", + "other3" + ]; await Promise.all( getDevelopment.map(async (x) => { const _data = Object.assign(new DevelopmentHistory(), x); + + const techniqueActuals = x.development?.developmentProjectTechniqueActuals.flatMap(x => x.name) || []; + isDevelopment70 = techniqueActuals.length > 0 && dev70Lists.some(item => techniqueActuals.includes(item)); + isDevelopment20 = techniqueActuals.length > 0 && dev20Lists.some(item => techniqueActuals.includes(item)); + isDevelopment10 = techniqueActuals.length > 0 && dev10Lists.some(item => techniqueActuals.includes(item)); + if (x.type == "OFFICER") { await new CallAPI() .PostData(request, "/org/profile/development", { @@ -2555,9 +2597,9 @@ export class DevelopmentController extends Controller { reasonDevelopment70: x.development.reasonActual70, reasonDevelopment20: x.development.reasonActual20, reasonDevelopment10: x.development.reasonActual10, - isDevelopment70: x.development.isReasonActual70, - isDevelopment20: x.development.isReasonActual20, - isDevelopment10: x.development.isReasonActual10, + isDevelopment70: isDevelopment70, + isDevelopment20: isDevelopment20, + isDevelopment10: isDevelopment10, developmentTarget: null, developmentResults: null, developmentReport: null, @@ -2584,9 +2626,9 @@ export class DevelopmentController extends Controller { reasonDevelopment70: x.development.reasonActual70, reasonDevelopment20: x.development.reasonActual20, reasonDevelopment10: x.development.reasonActual10, - isDevelopment70: x.development.isReasonActual70, - isDevelopment20: x.development.isReasonActual20, - isDevelopment10: x.development.isReasonActual10, + isDevelopment70: isDevelopment70, + isDevelopment20: isDevelopment20, + isDevelopment10: isDevelopment10, developmentTarget: null, developmentResults: null, developmentReport: null, diff --git a/src/controllers/DevelopmentHistoryController.ts b/src/controllers/DevelopmentHistoryController.ts index e546a0c..5ab0f55 100644 --- a/src/controllers/DevelopmentHistoryController.ts +++ b/src/controllers/DevelopmentHistoryController.ts @@ -250,6 +250,7 @@ export class DevelopmentOfficerHistoryController extends Controller { .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" diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index bf63247..ff19bb7 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -16,6 +16,7 @@ import { isNotEmittedStatement } from "typescript"; @Tags("Report") @Security("bearerAuth") export class ReportController extends Controller { + private developmentRepository = AppDataSource.getRepository(Development); private developmentScholarshipRepository = AppDataSource.getRepository(DevelopmentScholarship); private viewDevScholarship = AppDataSource.getRepository(viewDevScholarship); /** @@ -44,6 +45,7 @@ export class ReportController extends Controller { .leftJoinAndSelect("development.strategyChild5Actual", "strategy5") .where("development.status = :status", { status: "FINISH" }) .andWhere("development.strategyChild1ActualId IS NOT NULL") + .andWhere("development.rootDnaId = :rootDnaId", { rootDnaId: rootId }) .select([ "development.id AS id", "development.projectName AS projectName", @@ -114,6 +116,7 @@ export class ReportController extends Controller { .leftJoinAndSelect("development.strategyChild1Actual", "strategy1") .where("development.status = :status", { status: "FINISH" }) .andWhere("development.strategyChild1ActualId IS NOT NULL") + .andWhere("development.rootDnaId = :rootDnaId", { rootDnaId: rootId }) .select([ "development.rootId AS rootId", "development.strategyChild1ActualId AS strategyId", @@ -377,10 +380,17 @@ export class ReportController extends Controller { return formattedGroup; }); + const dev = await this.developmentRepository.findOne({ + where: { rootDnaId: rootId }, + select: ["root", "year"] + }) + return new HttpSuccess({ template: "development", reportName: "development", data: { + root: dev && dev.root ? dev.root : "-", + year: dev && dev.year ? Extension.ToThaiNumber((dev.year+543).toString()) : "-", data: mappedDataDev, resultAllStrategy: reformattedData, sumDev1: Extension.ToThaiNumber(sumDev1.toLocaleString()) ?? "-", From cd6ef2711619e88ee417e51a41ee33d59916e237 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 10 Apr 2025 13:59:19 +0700 Subject: [PATCH 08/32] =?UTF-8?q?filter=20=E0=B8=AB=E0=B8=99=E0=B9=88?= =?UTF-8?q?=E0=B8=A7=E0=B8=A2=E0=B8=87=E0=B8=B2=E0=B8=99=20=E0=B8=A3?= =?UTF-8?q?=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=9B=E0=B8=A3?= =?UTF-8?q?=E0=B8=B0=E0=B8=A7=E0=B8=B1=E0=B8=95=E0=B8=B4=E0=B8=81=E0=B8=B2?= =?UTF-8?q?=E0=B8=A3=E0=B8=9D=E0=B8=B6=E0=B8=81=E0=B8=AD=E0=B8=9A=E0=B8=A3?= =?UTF-8?q?=E0=B8=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ReportController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index ff19bb7..d9ff0eb 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -441,7 +441,7 @@ export class ReportController extends Controller { .andWhere(body.year != 0 && body.year != null ? "development.year = :year" : "1=1", { year: body.year, }) - .andWhere(body.root != null ? "development.root = :root" : "1=1", { + .andWhere(body.root != null ? "developmentHistory.root = :root" : "1=1", { root: body.root, }) .andWhere("developmentHistory.type = :type", { type: "OFFICER" }) From 719da258758fcb82dba6796b1262595733196c4e Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 10 Apr 2025 15:04:17 +0700 Subject: [PATCH 09/32] =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7=E0=B8=B1?= =?UTF-8?q?=E0=B8=95=E0=B8=B4=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=9D=E0=B8=B6?= =?UTF-8?q?=E0=B8=81=E0=B8=AD=E0=B8=9A=E0=B8=A3=E0=B8=A1=E0=B8=A5=E0=B8=B9?= =?UTF-8?q?=E0=B8=81=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=87=20&=20=E0=B8=A3?= =?UTF-8?q?=E0=B8=B0=E0=B8=94=E0=B8=B1=E0=B8=9A=E0=B8=8A=E0=B8=B1=E0=B9=89?= =?UTF-8?q?=E0=B8=99=E0=B8=87=E0=B8=B2=E0=B8=99=E0=B8=A5=E0=B8=B9=E0=B8=81?= =?UTF-8?q?=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/DevelopmentController.ts | 2 +- src/controllers/ReportController.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index 95d2ae4..0e8e115 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -2434,7 +2434,7 @@ export class DevelopmentController extends Controller { ? item.posLevel.posLevelName : null : item.employeePosLevel - ? item.employeePosLevel.posLevelName + ? `${item.employeePosType.posTypeShortName ?? ""} ${item.employeePosLevel.posLevelName ?? ""}` : null, posExecutive: item.posExecutive, org: item.org, diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index d9ff0eb..3f1183d 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -505,7 +505,7 @@ export class ReportController extends Controller { .andWhere(body.year != 0 && body.year != null ? "development.year = :year" : "1=1", { year: body.year, }) - .andWhere(body.root != null ? "development.root = :root" : "1=1", { + .andWhere(body.root != null ? "developmentHistory.root = :root" : "1=1", { root: body.root, }) .andWhere("developmentHistory.type = :type", { type: "EMPLOYEE" }) From 60781ea2544e05eb3ec14c5d826be5e217238b59 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 10 Apr 2025 16:20:30 +0700 Subject: [PATCH 10/32] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1/=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82=20?= =?UTF-8?q?=E0=B8=81=E0=B8=A5=E0=B8=B8=E0=B9=88=E0=B8=A1=E0=B9=80=E0=B8=9B?= =?UTF-8?q?=E0=B9=89=E0=B8=B2=E0=B8=AB=E0=B8=A1=E0=B8=B2=E0=B8=A2=20(?= =?UTF-8?q?=E0=B8=A5=E0=B8=B9=E0=B8=81=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=87?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/DevelopmentController.ts | 88 ++++++++++++++++++------ 1 file changed, 68 insertions(+), 20 deletions(-) diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index 0e8e115..4310ce9 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -34,6 +34,8 @@ import { ActualGoal, CreateActualGoal } from "../entities/ActualGoal"; import { CreatePlannedGoal, PlannedGoal } from "../entities/PlannedGoal"; import { PosType } from "../entities/PosType"; import { PosLevel } from "../entities/PosLevel"; +import { EmployeePosType } from "../entities/EmployeePosType"; +import { EmployeePosLevel } from "../entities/EmployeePosLevel"; import { PlannedGoalPosition } from "../entities/PlannedGoalPosition"; import { CreateDevelopmentHistoryOBO, DevelopmentHistory } from "../entities/DevelopmentHistory"; import { DevelopmentProjectType } from "../entities/DevelopmentProjectType"; @@ -84,6 +86,8 @@ export class DevelopmentController extends Controller { private plannedGoalPositionRepository = AppDataSource.getRepository(PlannedGoalPosition); private posTypeRepository = AppDataSource.getRepository(PosType); private posLevelRepository = AppDataSource.getRepository(PosLevel); + private empPosTypeRepository = AppDataSource.getRepository(EmployeePosType); + private empPosLevelRepository = AppDataSource.getRepository(EmployeePosLevel); private strategyChild1Repository = AppDataSource.getRepository(StrategyChild1); private strategyChild2Repository = AppDataSource.getRepository(StrategyChild2); private strategyChild3Repository = AppDataSource.getRepository(StrategyChild3); @@ -367,19 +371,41 @@ export class DevelopmentController extends Controller { requestBody.positions.map(async (x) => { const _data = Object.assign(new PlannedGoalPosition(), x); if (x.posTypePlannedId != null) { - const checkId = await this.posTypeRepository.findOne({ - where: { id: x.posTypePlannedId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); + let checkId:any + if(requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + checkId = await this.empPosTypeRepository.findOne({ + where: { id: x.posTypePlannedId }, + }); + if (!checkId) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); + } + } + else { + checkId = await this.posTypeRepository.findOne({ + where: { id: x.posTypePlannedId }, + }); + if (!checkId) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); + } } } if (x.posLevelPlannedId != null) { - const checkId = await this.posLevelRepository.findOne({ - where: { id: x.posLevelPlannedId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); + let checkId:any + if (requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + checkId = await this.empPosLevelRepository.findOne({ + where: { id: x.posLevelPlannedId }, + }); + if (!checkId) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); + } + } + else { + checkId = await this.posLevelRepository.findOne({ + where: { id: x.posLevelPlannedId }, + }); + if (!checkId) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); + } } } const before = structuredClone(development); @@ -608,19 +634,41 @@ export class DevelopmentController extends Controller { requestBody.positions.map(async (x) => { const _data = Object.assign(new PlannedGoalPosition(), x); if (x.posTypePlannedId != null) { - const checkId = await this.posTypeRepository.findOne({ - where: { id: x.posTypePlannedId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); + let checkId:any + if(requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + checkId = await this.empPosTypeRepository.findOne({ + where: { id: x.posTypePlannedId }, + }); + if (!checkId) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); + } + } + else { + checkId = await this.posTypeRepository.findOne({ + where: { id: x.posTypePlannedId }, + }); + if (!checkId) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); + } } } if (x.posLevelPlannedId != null) { - const checkId = await this.posLevelRepository.findOne({ - where: { id: x.posLevelPlannedId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); + let checkId:any + if (requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + checkId = await this.empPosLevelRepository.findOne({ + where: { id: x.posLevelPlannedId }, + }); + if (!checkId) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); + } + } + else { + checkId = await this.posLevelRepository.findOne({ + where: { id: x.posLevelPlannedId }, + }); + if (!checkId) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); + } } } _data.createdUserId = request.user.sub; From dbfc678e9212543e459ea77aeb42c20db951f2ce Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 11 Apr 2025 10:58:34 +0700 Subject: [PATCH 11/32] =?UTF-8?q?migrate=20(=E0=B8=95=E0=B8=B1=E0=B8=94=20?= =?UTF-8?q?relation=20=E0=B8=9F=E0=B8=B4=E0=B8=A5=E0=B8=94=E0=B9=8C=20posT?= =?UTF-8?q?ype,=20posLevel,=20empPosType,=20empPosLevel)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/DevelopmentController.ts | 285 +++++++++--------- src/entities/ActualGoal.ts | 42 ++- src/entities/PlannedGoalPosition.ts | 42 ++- src/entities/PosLevel.ts | 14 +- src/entities/PosType.ts | 14 +- ...able_actualGoal_and_plannedGoalPosition.ts | 36 +++ 6 files changed, 255 insertions(+), 178 deletions(-) create mode 100644 src/migration/1744342850196-update_table_actualGoal_and_plannedGoalPosition.ts diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index 4310ce9..82c6d93 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -370,44 +370,44 @@ export class DevelopmentController extends Controller { await Promise.all( requestBody.positions.map(async (x) => { const _data = Object.assign(new PlannedGoalPosition(), x); - if (x.posTypePlannedId != null) { - let checkId:any - if(requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { - checkId = await this.empPosTypeRepository.findOne({ - where: { id: x.posTypePlannedId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); - } - } - else { - checkId = await this.posTypeRepository.findOne({ - where: { id: x.posTypePlannedId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); - } - } - } - if (x.posLevelPlannedId != null) { - let checkId:any - if (requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { - checkId = await this.empPosLevelRepository.findOne({ - where: { id: x.posLevelPlannedId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); - } - } - else { - checkId = await this.posLevelRepository.findOne({ - where: { id: x.posLevelPlannedId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); - } - } - } + // if (x.posTypePlannedId != null) { + // let checkId:any + // if(requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + // checkId = await this.empPosTypeRepository.findOne({ + // where: { id: x.posTypePlannedId }, + // }); + // if (!checkId) { + // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); + // } + // } + // else { + // checkId = await this.posTypeRepository.findOne({ + // where: { id: x.posTypePlannedId }, + // }); + // if (!checkId) { + // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); + // } + // } + // } + // if (x.posLevelPlannedId != null) { + // let checkId:any + // if (requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + // checkId = await this.empPosLevelRepository.findOne({ + // where: { id: x.posLevelPlannedId }, + // }); + // if (!checkId) { + // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); + // } + // } + // else { + // checkId = await this.posLevelRepository.findOne({ + // where: { id: x.posLevelPlannedId }, + // }); + // if (!checkId) { + // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); + // } + // } + // } const before = structuredClone(development); _data.createdUserId = request.user.sub; _data.createdFullName = request.user.name; @@ -492,32 +492,32 @@ export class DevelopmentController extends Controller { if (!development) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); } - if (requestBody.posTypeActualId != null) { - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Get Position Type.", - // }); - const checkId = await this.posTypeRepository.findOne({ - where: { id: requestBody.posTypeActualId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); - } - } - if (requestBody.posLevelActualId != null) { - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Get Position Level.", - // }); - const checkId = await this.posLevelRepository.findOne({ - where: { id: requestBody.posLevelActualId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); - } - } + // if (requestBody.posTypeActualId != null) { + // // addLogSequence(request, { + // // action: "database", + // // status: "success", + // // description: "Get Position Type.", + // // }); + // const checkId = await this.posTypeRepository.findOne({ + // where: { id: requestBody.posTypeActualId }, + // }); + // if (!checkId) { + // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); + // } + // } + // if (requestBody.posLevelActualId != null) { + // // addLogSequence(request, { + // // action: "database", + // // status: "success", + // // description: "Get Position Level.", + // // }); + // const checkId = await this.posLevelRepository.findOne({ + // where: { id: requestBody.posLevelActualId }, + // }); + // if (!checkId) { + // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); + // } + // } const before = structuredClone(development); const data = Object.assign(new ActualGoal(), requestBody); data.createdUserId = request.user.sub; @@ -633,44 +633,44 @@ export class DevelopmentController extends Controller { await Promise.all( requestBody.positions.map(async (x) => { const _data = Object.assign(new PlannedGoalPosition(), x); - if (x.posTypePlannedId != null) { - let checkId:any - if(requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { - checkId = await this.empPosTypeRepository.findOne({ - where: { id: x.posTypePlannedId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); - } - } - else { - checkId = await this.posTypeRepository.findOne({ - where: { id: x.posTypePlannedId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); - } - } - } - if (x.posLevelPlannedId != null) { - let checkId:any - if (requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { - checkId = await this.empPosLevelRepository.findOne({ - where: { id: x.posLevelPlannedId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); - } - } - else { - checkId = await this.posLevelRepository.findOne({ - where: { id: x.posLevelPlannedId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); - } - } - } + // if (x.posTypePlannedId != null) { + // let checkId:any + // if(requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + // checkId = await this.empPosTypeRepository.findOne({ + // where: { id: x.posTypePlannedId }, + // }); + // if (!checkId) { + // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); + // } + // } + // else { + // checkId = await this.posTypeRepository.findOne({ + // where: { id: x.posTypePlannedId }, + // }); + // if (!checkId) { + // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); + // } + // } + // } + // if (x.posLevelPlannedId != null) { + // let checkId:any + // if (requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + // checkId = await this.empPosLevelRepository.findOne({ + // where: { id: x.posLevelPlannedId }, + // }); + // if (!checkId) { + // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); + // } + // } + // else { + // checkId = await this.posLevelRepository.findOne({ + // where: { id: x.posLevelPlannedId }, + // }); + // if (!checkId) { + // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); + // } + // } + // } _data.createdUserId = request.user.sub; _data.createdFullName = request.user.name; _data.lastUpdateUserId = request.user.sub; @@ -759,32 +759,32 @@ export class DevelopmentController extends Controller { if (!development) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); } - if (requestBody.posTypeActualId != null) { - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Get Position Type.", - // }); - const checkId = await this.posTypeRepository.findOne({ - where: { id: requestBody.posTypeActualId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); - } - } - if (requestBody.posLevelActualId != null) { - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Get Position Level.", - // }); - const checkId = await this.posLevelRepository.findOne({ - where: { id: requestBody.posLevelActualId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); - } - } + // if (requestBody.posTypeActualId != null) { + // // addLogSequence(request, { + // // action: "database", + // // status: "success", + // // description: "Get Position Type.", + // // }); + // const checkId = await this.posTypeRepository.findOne({ + // where: { id: requestBody.posTypeActualId }, + // }); + // if (!checkId) { + // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); + // } + // } + // if (requestBody.posLevelActualId != null) { + // // addLogSequence(request, { + // // action: "database", + // // status: "success", + // // description: "Get Position Level.", + // // }); + // const checkId = await this.posLevelRepository.findOne({ + // where: { id: requestBody.posLevelActualId }, + // }); + // if (!checkId) { + // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); + // } + // } const before = structuredClone(development); Object.assign(development, requestBody); development.lastUpdateUserId = request.user.sub; @@ -2164,17 +2164,18 @@ export class DevelopmentController extends Controller { if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_PROJECT"); const getDevelopment = await this.developmentRepository.findOne({ where: { id: id }, + //posTypeActual relations: [ "developmentActualPeoples", "developmentPlannedPeoples", "developmentActualGoals", - "developmentActualGoals.posTypeActual", - "developmentActualGoals.posLevelActual", + // "developmentActualGoals.posTypeActual", + // "developmentActualGoals.posLevelActual", "developmentActualGoals", "developmentPlannedGoals", "developmentPlannedGoals.plannedGoalPositions", - "developmentPlannedGoals.plannedGoalPositions.posTypePlanned", - "developmentPlannedGoals.plannedGoalPositions.posLevelPlanned", + // "developmentPlannedGoals.plannedGoalPositions.posTypePlanned", + // "developmentPlannedGoals.plannedGoalPositions.posLevelPlanned", ], }); if (!getDevelopment) { @@ -2212,10 +2213,12 @@ export class DevelopmentController extends Controller { groupTarget: x.groupTarget, groupTargetSub: x.groupTargetSub, position: x.position, - posTypeId: x.posTypeActualId, - posType: x.posTypeActual == null ? null : x.posTypeActual.posTypeName, - posLevelId: x.posLevelActualId, - posLevel: x.posLevelActual == null ? null : x.posLevelActual.posLevelName, + // posTypeId: x.posTypeActualId, + // posType: x.posTypeActual == null ? null : x.posTypeActual.posTypeName, + // posLevelId: x.posLevelActualId, + // posLevel: x.posLevelActual == null ? null : x.posLevelActual.posLevelName, + posType: x.posTypeActual, + posLevel: x.posLevelActual, type: x.type, amount: x.amount, })), @@ -2237,10 +2240,12 @@ export class DevelopmentController extends Controller { id: y.id, position: y.position, posExecutive: y.posExecutive, - posTypeId: y.posTypePlannedId, - posType: y.posTypePlanned == null ? null : y.posTypePlanned.posTypeName, - posLevelId: y.posLevelPlannedId, - posLevel: y.posLevelPlanned == null ? null : y.posLevelPlanned.posLevelName, + // posTypeId: y.posTypePlannedId, + // posType: y.posTypePlanned == null ? null : y.posTypePlanned.posTypeName, + // posLevelId: y.posLevelPlannedId, + // posLevel: y.posLevelPlanned == null ? null : y.posLevelPlanned.posLevelName, + posType: y.posTypePlanned, + posLevel: y.posLevelPlanned, })), amount: x.amount, })), diff --git a/src/entities/ActualGoal.ts b/src/entities/ActualGoal.ts index cbe85aa..2fe2589 100644 --- a/src/entities/ActualGoal.ts +++ b/src/entities/ActualGoal.ts @@ -29,25 +29,39 @@ export class ActualGoal extends EntityBase { @Column({ nullable: true, - comment: "ประเภทตำแหน่ง", + comment: "ประเภทตำแหน่ง & กลุ่มงาน", default: null, }) - posTypeActualId: string; + posTypeActual: string; + + // @Column({ + // nullable: true, + // comment: "ประเภทตำแหน่ง", + // default: null, + // }) + // posTypeActualId: string; - @ManyToOne(() => PosType, (posType: PosType) => posType.actualGoals) - @JoinColumn({ name: "posTypeActualId" }) - posTypeActual: PosType; + // @ManyToOne(() => PosType, (posType: PosType) => posType.actualGoals) + // @JoinColumn({ name: "posTypeActualId" }) + // posTypeActual: PosType; @Column({ nullable: true, - comment: "ระดับตำแหน่ง", + comment: "ระดับตำแหน่ง & ระดับชั้นงาน", default: null, }) - posLevelActualId: string; + posLevelActual: string; - @ManyToOne(() => PosLevel, (posLevel: PosLevel) => posLevel.actualGoals) - @JoinColumn({ name: "posLevelActualId" }) - posLevelActual: PosLevel; + // @Column({ + // nullable: true, + // comment: "ระดับตำแหน่ง", + // default: null, + // }) + // posLevelActualId: string; + + // @ManyToOne(() => PosLevel, (posLevel: PosLevel) => posLevel.actualGoals) + // @JoinColumn({ name: "posLevelActualId" }) + // posLevelActual: PosLevel; @Column({ nullable: true, @@ -82,10 +96,14 @@ export class CreateActualGoal { groupTargetSub: string | null; @Column() position: string | null; + // @Column() + // posTypeActualId: string | null; + // @Column() + // posLevelActualId: string | null; @Column() - posTypeActualId: string | null; + posTypeActual: string | null; @Column() - posLevelActualId: string | null; + posLevelActual: string | null; @Column() type: string | null; @Column() diff --git a/src/entities/PlannedGoalPosition.ts b/src/entities/PlannedGoalPosition.ts index 990c977..a5df81d 100644 --- a/src/entities/PlannedGoalPosition.ts +++ b/src/entities/PlannedGoalPosition.ts @@ -22,25 +22,39 @@ export class PlannedGoalPosition extends EntityBase { @Column({ nullable: true, - comment: "ประเภทตำแหน่ง", + comment: "ประเภทตำแหน่ง & กลุ่มงาน", default: null, }) - posTypePlannedId: string; + posTypePlanned: string; - @ManyToOne(() => PosType, (posType: PosType) => posType.plannedGoalPositions) - @JoinColumn({ name: "posTypePlannedId" }) - posTypePlanned: PosType; + // @Column({ + // nullable: true, + // comment: "ประเภทตำแหน่ง", + // default: null, + // }) + // posTypePlannedId: string; + + // @ManyToOne(() => PosType, (posType: PosType) => posType.plannedGoalPositions) + // @JoinColumn({ name: "posTypePlannedId" }) + // posTypePlanned: PosType; @Column({ nullable: true, - comment: "ระดับตำแหน่ง", + comment: "ระดับตำแหน่ง & ระดับชั้นงาน", default: null, }) - posLevelPlannedId: string; + posLevelPlanned: string; - @ManyToOne(() => PosLevel, (posLevel: PosLevel) => posLevel.plannedGoalPositions) - @JoinColumn({ name: "posLevelPlannedId" }) - posLevelPlanned: PosLevel; + // @Column({ + // nullable: true, + // comment: "ระดับตำแหน่ง", + // default: null, + // }) + // posLevelPlannedId: string; + + // @ManyToOne(() => PosLevel, (posLevel: PosLevel) => posLevel.plannedGoalPositions) + // @JoinColumn({ name: "posLevelPlannedId" }) + // posLevelPlanned: PosLevel; @Column({ nullable: true, @@ -59,10 +73,14 @@ export class CreatePlannedGoalPosition { position: string | null; @Column() posExecutive: string | null; + // @Column() + // posTypePlannedId: string | null; + // @Column() + // posLevelPlannedId: string | null; @Column() - posTypePlannedId: string | null; + posTypePlanned: string | null; @Column() - posLevelPlannedId: string | null; + posLevelPlanned: string | null; } export type UpdatePlannedGoalPosition = Partial; diff --git a/src/entities/PosLevel.ts b/src/entities/PosLevel.ts index 705b6b8..3c686fa 100644 --- a/src/entities/PosLevel.ts +++ b/src/entities/PosLevel.ts @@ -48,14 +48,14 @@ export class PosLevel extends EntityBase { @JoinColumn({ name: "posTypeId" }) posType: PosType; - @OneToMany(() => ActualGoal, (actualGoal: ActualGoal) => actualGoal.posLevelActual) - actualGoals: ActualGoal[]; + // @OneToMany(() => ActualGoal, (actualGoal: ActualGoal) => actualGoal.posLevelActual) + // actualGoals: ActualGoal[]; - @OneToMany( - () => PlannedGoalPosition, - (plannedGoalPosition: PlannedGoalPosition) => plannedGoalPosition.posLevelPlanned, - ) - plannedGoalPositions: PlannedGoalPosition[]; + // @OneToMany( + // () => PlannedGoalPosition, + // (plannedGoalPosition: PlannedGoalPosition) => plannedGoalPosition.posLevelPlanned, + // ) + // plannedGoalPositions: PlannedGoalPosition[]; @OneToMany(() => DevelopmentHistory, (developmentHistory) => developmentHistory.posLevel) developmentHistorys: DevelopmentHistory[]; diff --git a/src/entities/PosType.ts b/src/entities/PosType.ts index d18e7fb..b28047b 100644 --- a/src/entities/PosType.ts +++ b/src/entities/PosType.ts @@ -28,14 +28,14 @@ export class PosType extends EntityBase { @OneToMany(() => PosLevel, (posLevel: PosLevel) => posLevel.posType) posLevels: PosLevel[]; - @OneToMany(() => ActualGoal, (actualGoal: ActualGoal) => actualGoal.posTypeActual) - actualGoals: ActualGoal[]; + // @OneToMany(() => ActualGoal, (actualGoal: ActualGoal) => actualGoal.posTypeActual) + // actualGoals: ActualGoal[]; - @OneToMany( - () => PlannedGoalPosition, - (plannedGoalPosition: PlannedGoalPosition) => plannedGoalPosition.posTypePlanned, - ) - plannedGoalPositions: PlannedGoalPosition[]; + // @OneToMany( + // () => PlannedGoalPosition, + // (plannedGoalPosition: PlannedGoalPosition) => plannedGoalPosition.posTypePlanned, + // ) + // plannedGoalPositions: PlannedGoalPosition[]; @OneToMany(() => DevelopmentHistory, (developmentHistory) => developmentHistory.posType) developmentHistorys: DevelopmentHistory[]; diff --git a/src/migration/1744342850196-update_table_actualGoal_and_plannedGoalPosition.ts b/src/migration/1744342850196-update_table_actualGoal_and_plannedGoalPosition.ts new file mode 100644 index 0000000..2888b6f --- /dev/null +++ b/src/migration/1744342850196-update_table_actualGoal_and_plannedGoalPosition.ts @@ -0,0 +1,36 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableActualGoalAndPlannedGoalPosition1744342850196 implements MigrationInterface { + name = 'UpdateTableActualGoalAndPlannedGoalPosition1744342850196' + + public async up(queryRunner: QueryRunner): Promise { + 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 \`plannedGoalPosition\` DROP FOREIGN KEY \`FK_4eef5d8c3ab92f7af4a762150a4\``); + await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP FOREIGN KEY \`FK_8e7e0bf6eebd99f58e9b47c6b05\``); + await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP COLUMN \`posLevelActualId\``); + await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP COLUMN \`posTypeActualId\``); + await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP COLUMN \`posLevelPlannedId\``); + await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP COLUMN \`posTypePlannedId\``); + await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD \`posTypeActual\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง & กลุ่มงาน'`); + await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD \`posLevelActual\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง & ระดับชั้นงาน'`); + await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD \`posTypePlanned\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง & กลุ่มงาน'`); + await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD \`posLevelPlanned\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง & ระดับชั้นงาน'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP COLUMN \`posLevelPlanned\``); + await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP COLUMN \`posTypePlanned\``); + await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP COLUMN \`posLevelActual\``); + await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP COLUMN \`posTypeActual\``); + await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD \`posTypePlannedId\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง'`); + await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD \`posLevelPlannedId\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง'`); + await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD \`posTypeActualId\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง'`); + await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD \`posLevelActualId\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง'`); + 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_4eef5d8c3ab92f7af4a762150a4\` FOREIGN KEY (\`posTypePlannedId\`) 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`); + } + +} From 2e7bef04759a5f4108a46bf72e959fc9792e847d Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 11 Apr 2025 15:38:32 +0700 Subject: [PATCH 12/32] validate --- src/controllers/DevelopmentController.ts | 320 ++++++++++++++--------- 1 file changed, 192 insertions(+), 128 deletions(-) diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index 82c6d93..82a70e9 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -370,44 +370,54 @@ export class DevelopmentController extends Controller { await Promise.all( requestBody.positions.map(async (x) => { const _data = Object.assign(new PlannedGoalPosition(), x); - // if (x.posTypePlannedId != null) { - // let checkId:any - // if(requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { - // checkId = await this.empPosTypeRepository.findOne({ - // where: { id: x.posTypePlannedId }, - // }); - // if (!checkId) { - // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); - // } - // } - // else { - // checkId = await this.posTypeRepository.findOne({ - // where: { id: x.posTypePlannedId }, - // }); - // if (!checkId) { - // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); - // } - // } - // } - // if (x.posLevelPlannedId != null) { - // let checkId:any - // if (requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { - // checkId = await this.empPosLevelRepository.findOne({ - // where: { id: x.posLevelPlannedId }, - // }); - // if (!checkId) { - // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); - // } - // } - // else { - // checkId = await this.posLevelRepository.findOne({ - // where: { id: x.posLevelPlannedId }, - // }); - // if (!checkId) { - // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); - // } - // } - // } + let checkPosType:any = null + let posTypeShortName:any = null + if (x.posTypePlanned != null) { + if(requestBody.groupTarget == "PERSONNEL" && + (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + checkPosType = await this.empPosTypeRepository.findOne({ + where: { posTypeName: x.posTypePlanned }, + }); + if (!checkPosType) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); + } + posTypeShortName = checkPosType.posTypeShortName + } + else { + checkPosType = await this.posTypeRepository.findOne({ + where: { posTypeName: x.posTypePlanned }, + }); + if (!checkPosType) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); + } + } + } + if (x.posLevelPlanned != null) { + let checkPosLevel:any + if (requestBody.groupTarget == "PERSONNEL" && + (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + checkPosLevel = await this.empPosLevelRepository.find({ + where: { + posTypeId: checkPosType.id + }, + }); + const mapShortName = checkPosLevel.flatMap((x:any) => `${posTypeShortName} ${x.posLevelName}`); + if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); + } + } + else { + checkPosLevel = await this.posLevelRepository.findOne({ + where: { + posLevelName: x.posLevelPlanned, + posTypeId: checkPosType.id + }, + }); + if (!checkPosLevel) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); + } + } + } const before = structuredClone(development); _data.createdUserId = request.user.sub; _data.createdFullName = request.user.name; @@ -492,32 +502,54 @@ export class DevelopmentController extends Controller { if (!development) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); } - // if (requestBody.posTypeActualId != null) { - // // addLogSequence(request, { - // // action: "database", - // // status: "success", - // // description: "Get Position Type.", - // // }); - // const checkId = await this.posTypeRepository.findOne({ - // where: { id: requestBody.posTypeActualId }, - // }); - // if (!checkId) { - // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); - // } - // } - // if (requestBody.posLevelActualId != null) { - // // addLogSequence(request, { - // // action: "database", - // // status: "success", - // // description: "Get Position Level.", - // // }); - // const checkId = await this.posLevelRepository.findOne({ - // where: { id: requestBody.posLevelActualId }, - // }); - // if (!checkId) { - // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); - // } - // } + let checkPosType:any = null + let posTypeShortName:any = null + if (requestBody.posTypeActual != null) { + if(requestBody.groupTarget == "PERSONNEL" && + (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + checkPosType = await this.empPosTypeRepository.findOne({ + where: { posTypeName: requestBody.posTypeActual }, + }); + if (!checkPosType) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); + } + posTypeShortName = checkPosType.posTypeShortName + } + else { + checkPosType = await this.posTypeRepository.findOne({ + where: { posTypeName: requestBody.posTypeActual }, + }); + if (!checkPosType) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); + } + } + } + if (requestBody.posLevelActual != null) { + let checkPosLevel:any + if (requestBody.groupTarget == "PERSONNEL" && + (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + checkPosLevel = await this.empPosLevelRepository.find({ + where: { + posTypeId: checkPosType.id + }, + }); + const mapShortName = checkPosLevel.flatMap((x:any) => `${posTypeShortName} ${x.posLevelName}`); + if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); + } + } + else { + checkPosLevel = await this.posLevelRepository.findOne({ + where: { + posLevelName: requestBody.posLevelActual, + posTypeId: checkPosType.id + }, + }); + if (!checkPosLevel) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); + } + } + } const before = structuredClone(development); const data = Object.assign(new ActualGoal(), requestBody); data.createdUserId = request.user.sub; @@ -633,44 +665,54 @@ export class DevelopmentController extends Controller { await Promise.all( requestBody.positions.map(async (x) => { const _data = Object.assign(new PlannedGoalPosition(), x); - // if (x.posTypePlannedId != null) { - // let checkId:any - // if(requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { - // checkId = await this.empPosTypeRepository.findOne({ - // where: { id: x.posTypePlannedId }, - // }); - // if (!checkId) { - // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); - // } - // } - // else { - // checkId = await this.posTypeRepository.findOne({ - // where: { id: x.posTypePlannedId }, - // }); - // if (!checkId) { - // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); - // } - // } - // } - // if (x.posLevelPlannedId != null) { - // let checkId:any - // if (requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { - // checkId = await this.empPosLevelRepository.findOne({ - // where: { id: x.posLevelPlannedId }, - // }); - // if (!checkId) { - // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); - // } - // } - // else { - // checkId = await this.posLevelRepository.findOne({ - // where: { id: x.posLevelPlannedId }, - // }); - // if (!checkId) { - // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); - // } - // } - // } + let checkPosType:any = null + let posTypeShortName:any = null + if (x.posTypePlanned != null) { + if(requestBody.groupTarget == "PERSONNEL" && + (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + checkPosType = await this.empPosTypeRepository.findOne({ + where: { posTypeName: x.posTypePlanned }, + }); + if (!checkPosType) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); + } + posTypeShortName = checkPosType.posTypeShortName + } + else { + checkPosType = await this.posTypeRepository.findOne({ + where: { posTypeName: x.posTypePlanned }, + }); + if (!checkPosType) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); + } + } + } + if (x.posLevelPlanned != null) { + let checkPosLevel:any + if (requestBody.groupTarget == "PERSONNEL" && + (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + checkPosLevel = await this.empPosLevelRepository.find({ + where: { + posTypeId: checkPosType.id + }, + }); + const mapShortName = checkPosLevel.flatMap((x:any) => `${posTypeShortName} ${x.posLevelName}`); + if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); + } + } + else { + checkPosLevel = await this.posLevelRepository.findOne({ + where: { + posLevelName: x.posLevelPlanned, + posTypeId: checkPosType.id + }, + }); + if (!checkPosLevel) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); + } + } + } _data.createdUserId = request.user.sub; _data.createdFullName = request.user.name; _data.lastUpdateUserId = request.user.sub; @@ -759,32 +801,54 @@ export class DevelopmentController extends Controller { if (!development) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); } - // if (requestBody.posTypeActualId != null) { - // // addLogSequence(request, { - // // action: "database", - // // status: "success", - // // description: "Get Position Type.", - // // }); - // const checkId = await this.posTypeRepository.findOne({ - // where: { id: requestBody.posTypeActualId }, - // }); - // if (!checkId) { - // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); - // } - // } - // if (requestBody.posLevelActualId != null) { - // // addLogSequence(request, { - // // action: "database", - // // status: "success", - // // description: "Get Position Level.", - // // }); - // const checkId = await this.posLevelRepository.findOne({ - // where: { id: requestBody.posLevelActualId }, - // }); - // if (!checkId) { - // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); - // } - // } + let checkPosType:any = null + let posTypeShortName:any = null + if (requestBody.posTypeActual != null) { + if(requestBody.groupTarget == "PERSONNEL" && + (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + checkPosType = await this.empPosTypeRepository.findOne({ + where: { posTypeName: requestBody.posTypeActual }, + }); + if (!checkPosType) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); + } + posTypeShortName = checkPosType.posTypeShortName + } + else { + checkPosType = await this.posTypeRepository.findOne({ + where: { posTypeName: requestBody.posTypeActual }, + }); + if (!checkPosType) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); + } + } + } + if (requestBody.posLevelActual != null) { + let checkPosLevel:any + if (requestBody.groupTarget == "PERSONNEL" && + (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + checkPosLevel = await this.empPosLevelRepository.find({ + where: { + posTypeId: checkPosType.id + }, + }); + const mapShortName = checkPosLevel.flatMap((x:any) => `${posTypeShortName} ${x.posLevelName}`); + if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); + } + } + else { + checkPosLevel = await this.posLevelRepository.findOne({ + where: { + posLevelName: requestBody.posLevelActual, + posTypeId: checkPosType.id + }, + }); + if (!checkPosLevel) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); + } + } + } const before = structuredClone(development); Object.assign(development, requestBody); development.lastUpdateUserId = request.user.sub; From 2eec9e5f602886e4f8e6e91268d9ccb2911bb4b9 Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 11 Apr 2025 15:46:28 +0700 Subject: [PATCH 13/32] no message --- src/controllers/DevelopmentController.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index 82a70e9..dadb34e 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -372,7 +372,7 @@ export class DevelopmentController extends Controller { const _data = Object.assign(new PlannedGoalPosition(), x); let checkPosType:any = null let posTypeShortName:any = null - if (x.posTypePlanned != null) { + if (x.posTypePlanned) { if(requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { checkPosType = await this.empPosTypeRepository.findOne({ @@ -392,7 +392,7 @@ export class DevelopmentController extends Controller { } } } - if (x.posLevelPlanned != null) { + if (x.posLevelPlanned) { let checkPosLevel:any if (requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { @@ -504,7 +504,7 @@ export class DevelopmentController extends Controller { } let checkPosType:any = null let posTypeShortName:any = null - if (requestBody.posTypeActual != null) { + if (requestBody.posTypeActual) { if(requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { checkPosType = await this.empPosTypeRepository.findOne({ @@ -524,7 +524,7 @@ export class DevelopmentController extends Controller { } } } - if (requestBody.posLevelActual != null) { + if (requestBody.posLevelActual) { let checkPosLevel:any if (requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { @@ -667,7 +667,7 @@ export class DevelopmentController extends Controller { const _data = Object.assign(new PlannedGoalPosition(), x); let checkPosType:any = null let posTypeShortName:any = null - if (x.posTypePlanned != null) { + if (x.posTypePlanned) { if(requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { checkPosType = await this.empPosTypeRepository.findOne({ @@ -687,7 +687,7 @@ export class DevelopmentController extends Controller { } } } - if (x.posLevelPlanned != null) { + if (x.posLevelPlanned) { let checkPosLevel:any if (requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { @@ -803,7 +803,7 @@ export class DevelopmentController extends Controller { } let checkPosType:any = null let posTypeShortName:any = null - if (requestBody.posTypeActual != null) { + if (requestBody.posTypeActual) { if(requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { checkPosType = await this.empPosTypeRepository.findOne({ @@ -823,7 +823,7 @@ export class DevelopmentController extends Controller { } } } - if (requestBody.posLevelActual != null) { + if (requestBody.posLevelActual) { let checkPosLevel:any if (requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { From bb6364e7c0fdf3eaa91e091a89a3640e6c06c461 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Thu, 17 Apr 2025 14:33:12 +0700 Subject: [PATCH 14/32] fix --- src/controllers/ReportController.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 3f1183d..7ad3c23 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -590,15 +590,15 @@ export class ReportController extends Controller { break; case "NOABROAD": getDevelopment.scholarshipType = - "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่ไม่มีการไปต่างประเทศ)"; + "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยงานภายนอก (หลักสูตรที่ไม่มีการไปต่างประเทศ)"; break; case "ABROAD": getDevelopment.scholarshipType = - "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่มีการไปต่างประเทศ)"; + "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยงานภายนอก (หลักสูตรที่มีการไปต่างประเทศ)"; break; case "EXECUTIVE": getDevelopment.scholarshipType = - "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรประเภทนักบริหาร)"; + "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยงานภายนอก (หลักสูตรประเภทนักบริหาร)"; break; case "RESEARCH": getDevelopment.scholarshipType = @@ -608,13 +608,13 @@ export class ReportController extends Controller { break; } } - + let _orgNoNewLine = (getDevelopment.org ? getDevelopment.org : "-").replace(/\n/g, " "); const formattedData = { id: getDevelopment.id, firstName: getDevelopment.firstName, lastName: getDevelopment.lastName, position: getDevelopment.position, - org: getDevelopment.org, + org: _orgNoNewLine, degreeLevel: getDevelopment.degreeLevel, course: getDevelopment.course, field: getDevelopment.field, From 101eabbac0ba711dbe3c2bce40b31007dde7fa50 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 18 Apr 2025 14:34:11 +0700 Subject: [PATCH 15/32] add api portfolio/user --- src/controllers/PortfolioController.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/controllers/PortfolioController.ts b/src/controllers/PortfolioController.ts index d027420..294b7f6 100644 --- a/src/controllers/PortfolioController.ts +++ b/src/controllers/PortfolioController.ts @@ -59,6 +59,30 @@ export class PortfolioController extends Controller { 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 รายละเอียดรายการผลงาน * From 8c7cbef72b6715446b0eb9d874378b6181dbc0fd Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 22 Apr 2025 10:14:31 +0700 Subject: [PATCH 16/32] =?UTF-8?q?[Edit=20SIT=20=E0=B8=A3=E0=B8=B0=E0=B8=9A?= =?UTF-8?q?=E0=B8=9A=E0=B8=9E=E0=B8=B1=E0=B8=92=E0=B8=99=E0=B8=B2]=20?= =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=97?= =?UTF-8?q?=E0=B8=B5=E0=B9=88=E0=B8=95=E0=B9=89=E0=B8=AD=E0=B8=87=E0=B9=81?= =?UTF-8?q?=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82=20#1331?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/DevelopmentController.ts | 10 ++++--- .../DevelopmentScholarshipController.ts | 4 +-- src/controllers/ReportController.ts | 2 +- src/entities/DevelopmentAddress.ts | 26 ++++++++++++++++++- src/entities/DevelopmentScholarship.ts | 16 +++++++++--- ...ddress_and_developScholaship_add_fields.ts | 24 +++++++++++++++++ 6 files changed, 71 insertions(+), 11 deletions(-) create mode 100644 src/migration/1745290442590-update_table_developAddress_and_developScholaship_add_fields.ts diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index dadb34e..a18787a 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -2568,9 +2568,9 @@ export class DevelopmentController extends Controller { } /** - * API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab6 ส่งบันทึกทะเบียนประวัติ + * API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab6 ส่งบันทึกทะเบียนประวัติ (ข้อมูลผลงาน>การฝึกอบรม/ดูงาน) * - * @summary DEV_00 - รายละเอียดโครงการ/หลักสูตรการฝึกอบรมtab6 ส่งบันทึกทะเบียนประวัติ # + * @summary DEV_00 - รายละเอียดโครงการ/หลักสูตรการฝึกอบรมtab6 ส่งบันทึกทะเบียนประวัติ (ข้อมูลผลงาน>การฝึกอบรม/ดูงาน) # * * @param {string} id Id โครงการ */ @@ -2598,6 +2598,7 @@ export class DevelopmentController extends Controller { startDate: x.dateStart, endDate: x.dateEnd, isDate: true, + developmentId: id }) .then((x) => { _data.isDone = true; @@ -2620,6 +2621,7 @@ export class DevelopmentController extends Controller { startDate: x.dateStart, endDate: x.dateEnd, isDate: true, + developmentId: id }) .then((x) => { _data.isDone = true; @@ -2644,9 +2646,9 @@ export class DevelopmentController extends Controller { } /** - * API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab6 IDP ส่งบันทึกทะเบียนประวัติ + * API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab6 IDP ส่งบันทึกทะเบียนประวัติ (ข้อมูลผลงาน>ผลการประเมินการปฏิบัติราชการ) * - * @summary DEV_00 - รายละเอียดโครงการ/หลักสูตรการฝึกอบรมtab6 IDP ส่งบันทึกทะเบียนประวัติ # + * @summary DEV_00 - รายละเอียดโครงการ/หลักสูตรการฝึกอบรมtab6 IDP ส่งบันทึกทะเบียนประวัติ (ข้อมูลผลงาน>ผลการประเมินการปฏิบัติราชการ)# * * @param {string} id Id โครงการ */ diff --git a/src/controllers/DevelopmentScholarshipController.ts b/src/controllers/DevelopmentScholarshipController.ts index 117dfb3..54bead1 100644 --- a/src/controllers/DevelopmentScholarshipController.ts +++ b/src/controllers/DevelopmentScholarshipController.ts @@ -322,7 +322,7 @@ export class DevelopmentScholarshipController extends Controller { bookNo: getDevelopment.bookNo ? getDevelopment.bookNo : null, bookNoDate: getDevelopment.bookNoDate ? getDevelopment.bookNoDate : null, bookApproveDate: getDevelopment.bookApproveDate ? getDevelopment.bookApproveDate : null, - useOfficialTime: getDevelopment.useOfficialTime ? getDevelopment.useOfficialTime : false, + useOfficialTime: getDevelopment.useOfficialTime ? getDevelopment.useOfficialTime : null, changeDetail: getDevelopment.changeDetail ? getDevelopment.changeDetail : null, scholarshipType: getDevelopment.scholarshipType ? getDevelopment.scholarshipType : null, fundType: getDevelopment.fundType ? getDevelopment.fundType : null, @@ -484,7 +484,7 @@ export class DevelopmentScholarshipController extends Controller { bookNo: getDevelopment.bookNo ? getDevelopment.bookNo : null, bookNoDate: getDevelopment.bookNoDate ? getDevelopment.bookNoDate : null, bookApproveDate: getDevelopment.bookApproveDate ? getDevelopment.bookApproveDate : null, - useOfficialTime: getDevelopment.useOfficialTime ? getDevelopment.useOfficialTime : false, + useOfficialTime: getDevelopment.useOfficialTime ? getDevelopment.useOfficialTime : null, changeDetail: getDevelopment.changeDetail ? getDevelopment.changeDetail : null, scholarshipType: getDevelopment.scholarshipType ? getDevelopment.scholarshipType : null, fundType: getDevelopment.fundType ? getDevelopment.fundType : null, diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 7ad3c23..a6b6913 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -650,7 +650,7 @@ export class ReportController extends Controller { : Extension.ToThaiNumber(Extension.ToThaiFullDate3(getDevelopment.graduatedDate)), graduatedReason: getDevelopment.graduatedReason == null ? "" : getDevelopment.graduatedReason, useOfficialTime: getDevelopment.useOfficialTime, - useOffTime: getDevelopment.useOfficialTime == true ? "🗹 ใช้ ☐ ไม่ใช้" : "☐ ใช้ 🗹 ไม่ใช้", + useOffTime: getDevelopment.useOfficialTime == "NOUSETIME" ? "🗹 ใช้ ☐ ไม่ใช้" : "☐ ใช้ 🗹 ไม่ใช้", isGraduated: getDevelopment.isGraduated, isG1: getDevelopment.isGraduated == true ? "🗹" : "☐", isG2: getDevelopment.isGraduated == true ? "☐" : "🗹", diff --git a/src/entities/DevelopmentAddress.ts b/src/entities/DevelopmentAddress.ts index 1629293..8de2fa8 100644 --- a/src/entities/DevelopmentAddress.ts +++ b/src/entities/DevelopmentAddress.ts @@ -20,7 +20,7 @@ export class DevelopmentAddress extends EntityBase { @Column({ nullable: true, - comment: "โครงการ/หลักสูตรการฝึกอบรม", + comment: "ชื่อจังหวัด (กรณีเลือกสถานที่ดำเนินการในประเทศ)", default: null, }) provinceName: string; @@ -32,6 +32,20 @@ export class DevelopmentAddress extends EntityBase { }) 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; @@ -39,6 +53,16 @@ export class DevelopmentAddress extends EntityBase { export class CreateDevelopmentAddress { @Column() address: string | null; + @Column() provinceId: string | null; + + @Column() + addressType?: string | null; + + @Column() + provinceName?: string | null; + + @Column() + country?: string | null; } diff --git a/src/entities/DevelopmentScholarship.ts b/src/entities/DevelopmentScholarship.ts index efa05ba..c0ef3cf 100644 --- a/src/entities/DevelopmentScholarship.ts +++ b/src/entities/DevelopmentScholarship.ts @@ -301,7 +301,7 @@ export class DevelopmentScholarship extends EntityBase { comment: "ใช้เวลาราชการ", default: false, }) - useOfficialTime: boolean; + useOfficialTime: string; @Column({ nullable: true, @@ -567,6 +567,13 @@ export class DevelopmentScholarship extends EntityBase { default: null, }) graduatedReason: string; + + @Column({ + nullable: true, + comment: "เงินอื่นๆ", + default: null, + }) + budgetSourceOther: number; } export class CreateDevelopmentScholarship { rootId: string | null; @@ -604,7 +611,7 @@ export class CreateDevelopmentScholarship { bookNo: string | null; bookNoDate: Date | null; bookApproveDate: Date | null; - useOfficialTime: boolean | false; + useOfficialTime: string | null; changeDetail: string | null; scholarshipType: string | null; fundType: string | null; @@ -631,6 +638,7 @@ export class CreateDevelopmentScholarship { totalPeriod: string | null; planType: string | null; isNoUseBudget: boolean | null; + budgetSourceOther?: number | null; } export class UpdateDevelopmentScholarship { @@ -669,7 +677,7 @@ export class UpdateDevelopmentScholarship { bookNo: string | null; bookNoDate: Date | null; bookApproveDate: Date | null; - useOfficialTime: boolean | false; + useOfficialTime: string | null; changeDetail: string | null; scholarshipType: string | null; fundType: string | null; @@ -696,6 +704,7 @@ export class UpdateDevelopmentScholarship { totalPeriod: string | null; planType: string | null; isNoUseBudget: boolean | null; + budgetSourceOther?: number | null; } export class UpdateDevelopmentScholarshipUser { @@ -706,4 +715,5 @@ export class UpdateDevelopmentScholarshipUser { isGraduated: boolean | null; graduatedDate: Date | null; graduatedReason: string | null; + budgetSourceOther?: number | null; } diff --git a/src/migration/1745290442590-update_table_developAddress_and_developScholaship_add_fields.ts b/src/migration/1745290442590-update_table_developAddress_and_developScholaship_add_fields.ts new file mode 100644 index 0000000..001ec46 --- /dev/null +++ b/src/migration/1745290442590-update_table_developAddress_and_developScholaship_add_fields.ts @@ -0,0 +1,24 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableDevelopAddressAndDevelopScholashipAddFields1745290442590 implements MigrationInterface { + name = 'UpdateTableDevelopAddressAndDevelopScholashipAddFields1745290442590' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`budgetSourceOther\` int NULL COMMENT 'เงินอื่นๆ'`); + await queryRunner.query(`ALTER TABLE \`developmentAddress\` ADD \`addressType\` varchar(255) NULL COMMENT 'สถานที่ดำเนินการ ในประเทศ(IN_COUNTRY) หรือ ต่างประเทศ(ABROAD)'`); + await queryRunner.query(`ALTER TABLE \`developmentAddress\` ADD \`country\` varchar(255) NULL COMMENT 'ชื่อประเทศ (กรณีเลือกสถานที่ดำเนินการต่างประเทศ)'`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`useOfficialTime\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`useOfficialTime\` varchar(255) NOT NULL COMMENT 'ใช้เวลาราชการ' DEFAULT 0`); + await queryRunner.query(`ALTER TABLE \`developmentAddress\` CHANGE \`provinceName\` \`provinceName\` varchar(255) NULL COMMENT 'ชื่อจังหวัด (กรณีเลือกสถานที่ดำเนินการในประเทศ)'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentAddress\` CHANGE \`provinceName\` \`provinceName\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม'`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`useOfficialTime\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`useOfficialTime\` tinyint NOT NULL COMMENT 'ใช้เวลาราชการ' DEFAULT '0'`); + await queryRunner.query(`ALTER TABLE \`developmentAddress\` DROP COLUMN \`country\``); + await queryRunner.query(`ALTER TABLE \`developmentAddress\` DROP COLUMN \`addressType\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`budgetSourceOther\``); + } + +} From 588178f042016a0a5d645521991c32981287868e Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 22 Apr 2025 16:27:56 +0700 Subject: [PATCH 17/32] =?UTF-8?q?migrate=20&=20=E0=B9=80=E0=B8=9E=E0=B8=B4?= =?UTF-8?q?=E0=B9=88=E0=B8=A1=E0=B8=9F=E0=B8=B4=E0=B8=A5=E0=B8=94=E0=B9=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DevelopmentScholarshipController.ts | 1 + src/entities/DevelopmentScholarship.ts | 8 ++++---- ...8-update_table_developScholaship_edit_type.ts | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 src/migration/1745313881448-update_table_developScholaship_edit_type.ts diff --git a/src/controllers/DevelopmentScholarshipController.ts b/src/controllers/DevelopmentScholarshipController.ts index 54bead1..d3df7e8 100644 --- a/src/controllers/DevelopmentScholarshipController.ts +++ b/src/controllers/DevelopmentScholarshipController.ts @@ -519,6 +519,7 @@ export class DevelopmentScholarshipController extends Controller { 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); } diff --git a/src/entities/DevelopmentScholarship.ts b/src/entities/DevelopmentScholarship.ts index c0ef3cf..976598e 100644 --- a/src/entities/DevelopmentScholarship.ts +++ b/src/entities/DevelopmentScholarship.ts @@ -573,7 +573,7 @@ export class DevelopmentScholarship extends EntityBase { comment: "เงินอื่นๆ", default: null, }) - budgetSourceOther: number; + budgetSourceOther: string; } export class CreateDevelopmentScholarship { rootId: string | null; @@ -638,7 +638,7 @@ export class CreateDevelopmentScholarship { totalPeriod: string | null; planType: string | null; isNoUseBudget: boolean | null; - budgetSourceOther?: number | null; + budgetSourceOther?: string | null; } export class UpdateDevelopmentScholarship { @@ -704,7 +704,7 @@ export class UpdateDevelopmentScholarship { totalPeriod: string | null; planType: string | null; isNoUseBudget: boolean | null; - budgetSourceOther?: number | null; + budgetSourceOther?: string | null; } export class UpdateDevelopmentScholarshipUser { @@ -715,5 +715,5 @@ export class UpdateDevelopmentScholarshipUser { isGraduated: boolean | null; graduatedDate: Date | null; graduatedReason: string | null; - budgetSourceOther?: number | null; + budgetSourceOther?: string | null; } diff --git a/src/migration/1745313881448-update_table_developScholaship_edit_type.ts b/src/migration/1745313881448-update_table_developScholaship_edit_type.ts new file mode 100644 index 0000000..c6c393f --- /dev/null +++ b/src/migration/1745313881448-update_table_developScholaship_edit_type.ts @@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableDevelopScholashipEditType1745313881448 implements MigrationInterface { + name = 'UpdateTableDevelopScholashipEditType1745313881448' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`budgetSourceOther\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`budgetSourceOther\` varchar(255) NULL COMMENT 'เงินอื่นๆ'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`budgetSourceOther\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`budgetSourceOther\` int NULL COMMENT 'เงินอื่นๆ'`); + } + +} From 65899d936a6a1f42e567fcdb15fd3b2b322e0aea Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 23 Apr 2025 09:27:31 +0700 Subject: [PATCH 18/32] =?UTF-8?q?api=20=E0=B8=A3=E0=B8=B2=E0=B8=A2?= =?UTF-8?q?=E0=B8=A5=E0=B8=B0=E0=B9=80=E0=B8=AD=E0=B8=B5=E0=B8=A2=E0=B8=94?= =?UTF-8?q?=E0=B8=97=E0=B8=B8=E0=B8=99=20&=20=E0=B9=81=E0=B8=81=E0=B9=89?= =?UTF-8?q?=E0=B9=84=E0=B8=82=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=A5=E0=B8=B0?= =?UTF-8?q?=E0=B9=80=E0=B8=AD=E0=B8=B5=E0=B8=A2=E0=B8=94=E0=B8=97=E0=B8=B8?= =?UTF-8?q?=E0=B8=99=20=E0=B8=AA=E0=B8=B3=E0=B8=AB=E0=B8=A3=E0=B8=B1?= =?UTF-8?q?=E0=B8=9A=E0=B9=80=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=AB=E0=B8=99?= =?UTF-8?q?=E0=B9=89=E0=B8=B2=E0=B8=97=E0=B8=B5=E0=B9=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DevelopmentScholarshipController.ts | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/src/controllers/DevelopmentScholarshipController.ts b/src/controllers/DevelopmentScholarshipController.ts index d3df7e8..8587ed5 100644 --- a/src/controllers/DevelopmentScholarshipController.ts +++ b/src/controllers/DevelopmentScholarshipController.ts @@ -559,6 +559,41 @@ export class DevelopmentScholarshipController extends Controller { 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 * @@ -622,6 +657,36 @@ export class DevelopmentScholarshipController extends Controller { 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 เปลี่ยนสถานะ * From 374bec32e486c611be4b9f9488d744a0b3d412a1 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 2 May 2025 15:14:49 +0700 Subject: [PATCH 19/32] fix --- src/controllers/StrategyController.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controllers/StrategyController.ts b/src/controllers/StrategyController.ts index bd29960..1f5b4c0 100644 --- a/src/controllers/StrategyController.ts +++ b/src/controllers/StrategyController.ts @@ -254,6 +254,7 @@ export class StrategyController extends Controller { switch (body.levelnode) { case 0: const ckOrder = await this.strategy1Repo.findOne({ + where: {}, order: { order: "DESC" }, }); strategyRepo = this.strategy1Repo; From e16390b78737709766ad30552a413512e8f0ca8c Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Fri, 13 Jun 2025 14:40:43 +0700 Subject: [PATCH 20/32] fix sort developmentAddresss get tab3 --- src/controllers/DevelopmentController.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index a18787a..db37d6c 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -2385,8 +2385,7 @@ export class DevelopmentController extends Controller { dateStart: getDevelopment.dateStart, dateEnd: getDevelopment.dateEnd, totalDate: getDevelopment.totalDate, - developmentAddresss: - getDevelopment.developmentAddresss == null ? null : getDevelopment.developmentAddresss, + developmentAddresss: getDevelopment.developmentAddresss == null ? null : getDevelopment.developmentAddresss.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime()), }; return new HttpSuccess(_getDevelopment); } From d51357e715d4ddb7f044bd84cff6f9cc227c0ffa Mon Sep 17 00:00:00 2001 From: Moss <> Date: Mon, 16 Jun 2025 21:34:15 +0700 Subject: [PATCH 21/32] migrate dna --- src/controllers/DevelopmentController.ts | 251 ++++++++++++------ .../DevelopmentScholarshipController.ts | 31 ++- src/entities/DevelopmentScholarship.ts | 18 ++ .../1743061489009-update_strategyadddorder.ts | 22 -- ...able_actualGoal_and_plannedGoalPosition.ts | 36 --- ...ddress_and_developScholaship_add_fields.ts | 24 -- ...pdate_table_developScholaship_edit_type.ts | 16 -- .../1750083465733-update30062025604.ts | 14 + .../1750083913468-update30062025605.ts | 14 + 9 files changed, 243 insertions(+), 183 deletions(-) delete mode 100644 src/migration/1743061489009-update_strategyadddorder.ts delete mode 100644 src/migration/1744342850196-update_table_actualGoal_and_plannedGoalPosition.ts delete mode 100644 src/migration/1745290442590-update_table_developAddress_and_developScholaship_add_fields.ts delete mode 100644 src/migration/1745313881448-update_table_developScholaship_edit_type.ts create mode 100644 src/migration/1750083465733-update30062025604.ts create mode 100644 src/migration/1750083913468-update30062025605.ts diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index db37d6c..77986d2 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -370,20 +370,22 @@ export class DevelopmentController extends Controller { await Promise.all( requestBody.positions.map(async (x) => { const _data = Object.assign(new PlannedGoalPosition(), x); - let checkPosType:any = null - let posTypeShortName:any = null + let checkPosType: any = null; + let posTypeShortName: any = null; if (x.posTypePlanned) { - if(requestBody.groupTarget == "PERSONNEL" && - (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + if ( + requestBody.groupTarget == "PERSONNEL" && + (requestBody.groupTargetSub == "EMPLOYEE" || + requestBody.groupTargetSub == "EMPLOYEETEMP") + ) { checkPosType = await this.empPosTypeRepository.findOne({ where: { posTypeName: x.posTypePlanned }, }); if (!checkPosType) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); } - posTypeShortName = checkPosType.posTypeShortName - } - else { + posTypeShortName = checkPosType.posTypeShortName; + } else { checkPosType = await this.posTypeRepository.findOne({ where: { posTypeName: x.posTypePlanned }, }); @@ -393,24 +395,28 @@ export class DevelopmentController extends Controller { } } if (x.posLevelPlanned) { - let checkPosLevel:any - if (requestBody.groupTarget == "PERSONNEL" && - (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + let checkPosLevel: any; + if ( + requestBody.groupTarget == "PERSONNEL" && + (requestBody.groupTargetSub == "EMPLOYEE" || + requestBody.groupTargetSub == "EMPLOYEETEMP") + ) { checkPosLevel = await this.empPosLevelRepository.find({ - where: { - posTypeId: checkPosType.id + where: { + posTypeId: checkPosType.id, }, }); - const mapShortName = checkPosLevel.flatMap((x:any) => `${posTypeShortName} ${x.posLevelName}`); + const mapShortName = checkPosLevel.flatMap( + (x: any) => `${posTypeShortName} ${x.posLevelName}`, + ); if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); } - } - else { + } else { checkPosLevel = await this.posLevelRepository.findOne({ - where: { + where: { posLevelName: x.posLevelPlanned, - posTypeId: checkPosType.id + posTypeId: checkPosType.id, }, }); if (!checkPosLevel) { @@ -502,20 +508,21 @@ export class DevelopmentController extends Controller { if (!development) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); } - let checkPosType:any = null - let posTypeShortName:any = null + let checkPosType: any = null; + let posTypeShortName: any = null; if (requestBody.posTypeActual) { - if(requestBody.groupTarget == "PERSONNEL" && - (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + if ( + requestBody.groupTarget == "PERSONNEL" && + (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP") + ) { checkPosType = await this.empPosTypeRepository.findOne({ where: { posTypeName: requestBody.posTypeActual }, }); if (!checkPosType) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); } - posTypeShortName = checkPosType.posTypeShortName - } - else { + posTypeShortName = checkPosType.posTypeShortName; + } else { checkPosType = await this.posTypeRepository.findOne({ where: { posTypeName: requestBody.posTypeActual }, }); @@ -525,24 +532,27 @@ export class DevelopmentController extends Controller { } } if (requestBody.posLevelActual) { - let checkPosLevel:any - if (requestBody.groupTarget == "PERSONNEL" && - (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + let checkPosLevel: any; + if ( + requestBody.groupTarget == "PERSONNEL" && + (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP") + ) { checkPosLevel = await this.empPosLevelRepository.find({ - where: { - posTypeId: checkPosType.id + where: { + posTypeId: checkPosType.id, }, }); - const mapShortName = checkPosLevel.flatMap((x:any) => `${posTypeShortName} ${x.posLevelName}`); + const mapShortName = checkPosLevel.flatMap( + (x: any) => `${posTypeShortName} ${x.posLevelName}`, + ); if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); } - } - else { + } else { checkPosLevel = await this.posLevelRepository.findOne({ - where: { + where: { posLevelName: requestBody.posLevelActual, - posTypeId: checkPosType.id + posTypeId: checkPosType.id, }, }); if (!checkPosLevel) { @@ -665,20 +675,22 @@ export class DevelopmentController extends Controller { await Promise.all( requestBody.positions.map(async (x) => { const _data = Object.assign(new PlannedGoalPosition(), x); - let checkPosType:any = null - let posTypeShortName:any = null + let checkPosType: any = null; + let posTypeShortName: any = null; if (x.posTypePlanned) { - if(requestBody.groupTarget == "PERSONNEL" && - (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + if ( + requestBody.groupTarget == "PERSONNEL" && + (requestBody.groupTargetSub == "EMPLOYEE" || + requestBody.groupTargetSub == "EMPLOYEETEMP") + ) { checkPosType = await this.empPosTypeRepository.findOne({ where: { posTypeName: x.posTypePlanned }, }); if (!checkPosType) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); } - posTypeShortName = checkPosType.posTypeShortName - } - else { + posTypeShortName = checkPosType.posTypeShortName; + } else { checkPosType = await this.posTypeRepository.findOne({ where: { posTypeName: x.posTypePlanned }, }); @@ -688,24 +700,28 @@ export class DevelopmentController extends Controller { } } if (x.posLevelPlanned) { - let checkPosLevel:any - if (requestBody.groupTarget == "PERSONNEL" && - (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + let checkPosLevel: any; + if ( + requestBody.groupTarget == "PERSONNEL" && + (requestBody.groupTargetSub == "EMPLOYEE" || + requestBody.groupTargetSub == "EMPLOYEETEMP") + ) { checkPosLevel = await this.empPosLevelRepository.find({ - where: { - posTypeId: checkPosType.id + where: { + posTypeId: checkPosType.id, }, }); - const mapShortName = checkPosLevel.flatMap((x:any) => `${posTypeShortName} ${x.posLevelName}`); + const mapShortName = checkPosLevel.flatMap( + (x: any) => `${posTypeShortName} ${x.posLevelName}`, + ); if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); } - } - else { + } else { checkPosLevel = await this.posLevelRepository.findOne({ - where: { + where: { posLevelName: x.posLevelPlanned, - posTypeId: checkPosType.id + posTypeId: checkPosType.id, }, }); if (!checkPosLevel) { @@ -801,20 +817,21 @@ export class DevelopmentController extends Controller { if (!development) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); } - let checkPosType:any = null - let posTypeShortName:any = null + let checkPosType: any = null; + let posTypeShortName: any = null; if (requestBody.posTypeActual) { - if(requestBody.groupTarget == "PERSONNEL" && - (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + if ( + requestBody.groupTarget == "PERSONNEL" && + (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP") + ) { checkPosType = await this.empPosTypeRepository.findOne({ where: { posTypeName: requestBody.posTypeActual }, }); if (!checkPosType) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); } - posTypeShortName = checkPosType.posTypeShortName - } - else { + posTypeShortName = checkPosType.posTypeShortName; + } else { checkPosType = await this.posTypeRepository.findOne({ where: { posTypeName: requestBody.posTypeActual }, }); @@ -824,24 +841,27 @@ export class DevelopmentController extends Controller { } } if (requestBody.posLevelActual) { - let checkPosLevel:any - if (requestBody.groupTarget == "PERSONNEL" && - (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { + let checkPosLevel: any; + if ( + requestBody.groupTarget == "PERSONNEL" && + (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP") + ) { checkPosLevel = await this.empPosLevelRepository.find({ - where: { - posTypeId: checkPosType.id + where: { + posTypeId: checkPosType.id, }, }); - const mapShortName = checkPosLevel.flatMap((x:any) => `${posTypeShortName} ${x.posLevelName}`); + const mapShortName = checkPosLevel.flatMap( + (x: any) => `${posTypeShortName} ${x.posLevelName}`, + ); if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); } - } - else { + } else { checkPosLevel = await this.posLevelRepository.findOne({ - where: { + where: { posLevelName: requestBody.posLevelActual, - posTypeId: checkPosType.id + posTypeId: checkPosType.id, }, }); if (!checkPosLevel) { @@ -2046,7 +2066,13 @@ export class DevelopmentController extends Controller { @Query("node") node?: number | null, @Query("keyword") keyword?: string, ) { - // await new permission().PermissionOrgList(request, "SYS_DEV_SCHOLARSHIP"); + let _data = await new permission().PermissionOrgList(request, "SYS_DEV_PROJECT"); + await new CallAPI() + .PostData(request, "/org/finddna", _data) + .then((x) => { + _data = x; + }) + .catch((x) => {}); const [development, total] = await AppDataSource.getRepository(Development) .createQueryBuilder("development") .andWhere(year > 0 ? "development.year LIKE :year" : "1=1", { @@ -2086,6 +2112,56 @@ export class DevelopmentController extends Controller { keyword: `%${keyword}%`, }, ) + .andWhere( + _data.root != undefined && _data.root != null + ? _data.root[0] != null + ? `development.rootDnaId IN (:...root)` + : `development.rootDnaId is null` + : "1=1", + { + root: _data.root, + }, + ) + .andWhere( + _data.child1 != undefined && _data.child1 != null + ? _data.child1[0] != null + ? `development.child1DnaId IN (:...child1)` + : `development.child1DnaId is null` + : "1=1", + { + child1: _data.child1, + }, + ) + .andWhere( + _data.child2 != undefined && _data.child2 != null + ? _data.child2[0] != null + ? `development.child2DnaId IN (:...child2)` + : `development.child2DnaId is null` + : "1=1", + { + child2: _data.child2, + }, + ) + .andWhere( + _data.child3 != undefined && _data.child3 != null + ? _data.child3[0] != null + ? `development.child3DnaId IN (:...child3)` + : `development.child3DnaId is null` + : "1=1", + { + child3: _data.child3, + }, + ) + .andWhere( + _data.child4 != undefined && _data.child4 != null + ? _data.child4[0] != null + ? `development.child4DnaId IN (:...child4)` + : `development.child4DnaId is null` + : "1=1", + { + child4: _data.child4, + }, + ) .select([ "development.id", "development.projectName", @@ -2385,7 +2461,12 @@ export class DevelopmentController extends Controller { dateStart: getDevelopment.dateStart, dateEnd: getDevelopment.dateEnd, totalDate: getDevelopment.totalDate, - developmentAddresss: getDevelopment.developmentAddresss == null ? null : getDevelopment.developmentAddresss.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime()), + developmentAddresss: + getDevelopment.developmentAddresss == null + ? null + : getDevelopment.developmentAddresss.sort( + (a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime(), + ), }; return new HttpSuccess(_getDevelopment); } @@ -2597,7 +2678,7 @@ export class DevelopmentController extends Controller { startDate: x.dateStart, endDate: x.dateEnd, isDate: true, - developmentId: id + developmentId: id, }) .then((x) => { _data.isDone = true; @@ -2620,7 +2701,7 @@ export class DevelopmentController extends Controller { startDate: x.dateStart, endDate: x.dateEnd, isDate: true, - developmentId: id + developmentId: id, }) .then((x) => { _data.isDone = true; @@ -2658,7 +2739,7 @@ export class DevelopmentController extends Controller { relations: ["development", "development.developmentProjectTechniqueActuals"], }); - let isDevelopment70: boolean = false + let isDevelopment70: boolean = false; const dev70Lists = [ "on_the_job_training", "job_project_assignment", @@ -2671,18 +2752,18 @@ export class DevelopmentController extends Controller { "benchmarking", "problem_solving", "team_working", - "other1" + "other1", ]; - let isDevelopment20: boolean = false + let isDevelopment20: boolean = false; const dev20Lists = [ "coaching", "mentoring", "team_meeting", "consulting", "feedback", - "other2" + "other2", ]; - let isDevelopment10: boolean = false + let isDevelopment10: boolean = false; const dev10Lists = [ "self_learning", "classroom_training", @@ -2691,17 +2772,21 @@ export class DevelopmentController extends Controller { "e_training", "meeting", "seminar", - "other3" + "other3", ]; await Promise.all( getDevelopment.map(async (x) => { const _data = Object.assign(new DevelopmentHistory(), x); - const techniqueActuals = x.development?.developmentProjectTechniqueActuals.flatMap(x => x.name) || []; - isDevelopment70 = techniqueActuals.length > 0 && dev70Lists.some(item => techniqueActuals.includes(item)); - isDevelopment20 = techniqueActuals.length > 0 && dev20Lists.some(item => techniqueActuals.includes(item)); - isDevelopment10 = techniqueActuals.length > 0 && dev10Lists.some(item => techniqueActuals.includes(item)); - + const techniqueActuals = + x.development?.developmentProjectTechniqueActuals.flatMap((x) => x.name) || []; + isDevelopment70 = + techniqueActuals.length > 0 && dev70Lists.some((item) => techniqueActuals.includes(item)); + isDevelopment20 = + techniqueActuals.length > 0 && dev20Lists.some((item) => techniqueActuals.includes(item)); + isDevelopment10 = + techniqueActuals.length > 0 && dev10Lists.some((item) => techniqueActuals.includes(item)); + if (x.type == "OFFICER") { await new CallAPI() .PostData(request, "/org/profile/development", { diff --git a/src/controllers/DevelopmentScholarshipController.ts b/src/controllers/DevelopmentScholarshipController.ts index 8587ed5..af23f0a 100644 --- a/src/controllers/DevelopmentScholarshipController.ts +++ b/src/controllers/DevelopmentScholarshipController.ts @@ -161,7 +161,13 @@ export class DevelopmentScholarshipController extends Controller { @Query("year") year?: number, @Query("scholarshipType") scholarshipType?: string, ) { - await new permission().PermissionList(request, "SYS_DEV_SCHOLARSHIP"); + 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") @@ -226,6 +232,16 @@ export class DevelopmentScholarshipController extends Controller { ); }), ) + .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) @@ -264,6 +280,7 @@ export class DevelopmentScholarshipController extends Controller { 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, @@ -282,6 +299,9 @@ export class DevelopmentScholarshipController extends Controller { : 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, @@ -426,6 +446,7 @@ export class DevelopmentScholarshipController extends Controller { 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, @@ -444,6 +465,9 @@ export class DevelopmentScholarshipController extends Controller { : 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, @@ -567,7 +591,10 @@ export class DevelopmentScholarshipController extends Controller { * @param {string} id id รายการ */ @Get("admin/detail/{id}") - async GetDevelopemtScholarshipUserDetailAdminById(@Request() request: RequestWithUser, @Path() id: string) { + 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({ diff --git a/src/entities/DevelopmentScholarship.ts b/src/entities/DevelopmentScholarship.ts index 976598e..cd1c614 100644 --- a/src/entities/DevelopmentScholarship.ts +++ b/src/entities/DevelopmentScholarship.ts @@ -5,6 +5,13 @@ 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 หน่วยงาน", @@ -137,6 +144,13 @@ export class DevelopmentScholarship extends EntityBase { @JoinColumn({ name: "posTypeId" }) posType: PosType; + @Column({ + nullable: true, + comment: "id Dna หน่วยงาน", + default: null, + }) + guarantorRootDnaId: string; + @Column({ nullable: true, comment: "id หน่วยงาน", @@ -576,6 +590,7 @@ export class DevelopmentScholarship extends EntityBase { budgetSourceOther: string; } export class CreateDevelopmentScholarship { + rootDnaId?: string | null; rootId: string | null; root: string | null; org: string | null; @@ -591,6 +606,7 @@ export class CreateDevelopmentScholarship { posExecutive: string | null; posLevelId: string | null; posTypeId: string | null; + guarantorRootDnaId: string | null; guarantorRootId: string | null; guarantorRoot: string | null; guarantorOrg: string | null; @@ -642,6 +658,7 @@ export class CreateDevelopmentScholarship { } export class UpdateDevelopmentScholarship { + rootDnaId?: string | null; rootId: string | null; root: string | null; org: string | null; @@ -657,6 +674,7 @@ export class UpdateDevelopmentScholarship { posExecutive: string | null; posLevelId: string | null; posTypeId: string | null; + guarantorRootDnaId?: string | null; guarantorRootId?: string | null; guarantorRoot?: string | null; guarantorOrg?: string | null; diff --git a/src/migration/1743061489009-update_strategyadddorder.ts b/src/migration/1743061489009-update_strategyadddorder.ts deleted file mode 100644 index c6c6e16..0000000 --- a/src/migration/1743061489009-update_strategyadddorder.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateStrategyadddorder1743061489009 implements MigrationInterface { - name = 'UpdateStrategyadddorder1743061489009' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`strategyChild4\` ADD \`order\` int NULL COMMENT 'ลำดับความสำคัญ'`); - await queryRunner.query(`ALTER TABLE \`strategyChild3\` ADD \`order\` int NULL COMMENT 'ลำดับความสำคัญ'`); - await queryRunner.query(`ALTER TABLE \`strategyChild2\` ADD \`order\` int NULL COMMENT 'ลำดับความสำคัญ'`); - await queryRunner.query(`ALTER TABLE \`strategyChild1\` ADD \`order\` int NULL COMMENT 'ลำดับความสำคัญ'`); - await queryRunner.query(`ALTER TABLE \`strategyChild5\` ADD \`order\` int NULL COMMENT 'ลำดับความสำคัญ'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`strategyChild5\` DROP COLUMN \`order\``); - await queryRunner.query(`ALTER TABLE \`strategyChild1\` DROP COLUMN \`order\``); - await queryRunner.query(`ALTER TABLE \`strategyChild2\` DROP COLUMN \`order\``); - await queryRunner.query(`ALTER TABLE \`strategyChild3\` DROP COLUMN \`order\``); - await queryRunner.query(`ALTER TABLE \`strategyChild4\` DROP COLUMN \`order\``); - } - -} diff --git a/src/migration/1744342850196-update_table_actualGoal_and_plannedGoalPosition.ts b/src/migration/1744342850196-update_table_actualGoal_and_plannedGoalPosition.ts deleted file mode 100644 index 2888b6f..0000000 --- a/src/migration/1744342850196-update_table_actualGoal_and_plannedGoalPosition.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableActualGoalAndPlannedGoalPosition1744342850196 implements MigrationInterface { - name = 'UpdateTableActualGoalAndPlannedGoalPosition1744342850196' - - public async up(queryRunner: QueryRunner): Promise { - 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 \`plannedGoalPosition\` DROP FOREIGN KEY \`FK_4eef5d8c3ab92f7af4a762150a4\``); - await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP FOREIGN KEY \`FK_8e7e0bf6eebd99f58e9b47c6b05\``); - await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP COLUMN \`posLevelActualId\``); - await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP COLUMN \`posTypeActualId\``); - await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP COLUMN \`posLevelPlannedId\``); - await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP COLUMN \`posTypePlannedId\``); - await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD \`posTypeActual\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง & กลุ่มงาน'`); - await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD \`posLevelActual\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง & ระดับชั้นงาน'`); - await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD \`posTypePlanned\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง & กลุ่มงาน'`); - await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD \`posLevelPlanned\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง & ระดับชั้นงาน'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP COLUMN \`posLevelPlanned\``); - await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP COLUMN \`posTypePlanned\``); - await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP COLUMN \`posLevelActual\``); - await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP COLUMN \`posTypeActual\``); - await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD \`posTypePlannedId\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง'`); - await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD \`posLevelPlannedId\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง'`); - await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD \`posTypeActualId\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง'`); - await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD \`posLevelActualId\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง'`); - 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_4eef5d8c3ab92f7af4a762150a4\` FOREIGN KEY (\`posTypePlannedId\`) 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`); - } - -} diff --git a/src/migration/1745290442590-update_table_developAddress_and_developScholaship_add_fields.ts b/src/migration/1745290442590-update_table_developAddress_and_developScholaship_add_fields.ts deleted file mode 100644 index 001ec46..0000000 --- a/src/migration/1745290442590-update_table_developAddress_and_developScholaship_add_fields.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevelopAddressAndDevelopScholashipAddFields1745290442590 implements MigrationInterface { - name = 'UpdateTableDevelopAddressAndDevelopScholashipAddFields1745290442590' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`budgetSourceOther\` int NULL COMMENT 'เงินอื่นๆ'`); - await queryRunner.query(`ALTER TABLE \`developmentAddress\` ADD \`addressType\` varchar(255) NULL COMMENT 'สถานที่ดำเนินการ ในประเทศ(IN_COUNTRY) หรือ ต่างประเทศ(ABROAD)'`); - await queryRunner.query(`ALTER TABLE \`developmentAddress\` ADD \`country\` varchar(255) NULL COMMENT 'ชื่อประเทศ (กรณีเลือกสถานที่ดำเนินการต่างประเทศ)'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`useOfficialTime\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`useOfficialTime\` varchar(255) NOT NULL COMMENT 'ใช้เวลาราชการ' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`developmentAddress\` CHANGE \`provinceName\` \`provinceName\` varchar(255) NULL COMMENT 'ชื่อจังหวัด (กรณีเลือกสถานที่ดำเนินการในประเทศ)'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentAddress\` CHANGE \`provinceName\` \`provinceName\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`useOfficialTime\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`useOfficialTime\` tinyint NOT NULL COMMENT 'ใช้เวลาราชการ' DEFAULT '0'`); - await queryRunner.query(`ALTER TABLE \`developmentAddress\` DROP COLUMN \`country\``); - await queryRunner.query(`ALTER TABLE \`developmentAddress\` DROP COLUMN \`addressType\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`budgetSourceOther\``); - } - -} diff --git a/src/migration/1745313881448-update_table_developScholaship_edit_type.ts b/src/migration/1745313881448-update_table_developScholaship_edit_type.ts deleted file mode 100644 index c6c393f..0000000 --- a/src/migration/1745313881448-update_table_developScholaship_edit_type.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevelopScholashipEditType1745313881448 implements MigrationInterface { - name = 'UpdateTableDevelopScholashipEditType1745313881448' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`budgetSourceOther\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`budgetSourceOther\` varchar(255) NULL COMMENT 'เงินอื่นๆ'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`budgetSourceOther\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`budgetSourceOther\` int NULL COMMENT 'เงินอื่นๆ'`); - } - -} diff --git a/src/migration/1750083465733-update30062025604.ts b/src/migration/1750083465733-update30062025604.ts new file mode 100644 index 0000000..8fcdedc --- /dev/null +++ b/src/migration/1750083465733-update30062025604.ts @@ -0,0 +1,14 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class Update300620256041750083465733 implements MigrationInterface { + name = 'Update300620256041750083465733' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`rootDnaId\` varchar(255) NULL COMMENT 'id dna หน่วยงาน'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`rootDnaId\``); + } + +} diff --git a/src/migration/1750083913468-update30062025605.ts b/src/migration/1750083913468-update30062025605.ts new file mode 100644 index 0000000..644e8c2 --- /dev/null +++ b/src/migration/1750083913468-update30062025605.ts @@ -0,0 +1,14 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class Update300620256051750083913468 implements MigrationInterface { + name = 'Update300620256051750083913468' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`guarantorRootDnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`guarantorRootDnaId\``); + } + +} From 468f0b304fd2d4e5c26e1526eac063dbe9f1d0b9 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 15 Jul 2025 16:59:23 +0700 Subject: [PATCH 22/32] #1626 --- src/controllers/ReportController.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index a6b6913..e6b9826 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -604,6 +604,14 @@ export class ReportController extends Controller { getDevelopment.scholarshipType = "ศึกษา ฝึกอบรม ประชุม ดูงาน และปฏิบัติการวิจัย ณ ต่างประเทศ"; break; + case "STUDY": + getDevelopment.scholarshipType = + "ทุนการศึกษา ณ ต่างประเทศ"; + break; + case "TRAINING": + getDevelopment.scholarshipType = + "ทุนฝึกอบรม ณ ต่างประเทศ"; + break; default: break; } From ce39e89ccebe71f2e389a13997365840630d28af Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 16 Jul 2025 11:11:48 +0700 Subject: [PATCH 23/32] update --- src/controllers/DevelopmentController.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index 77986d2..5aa9632 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -2678,6 +2678,7 @@ export class DevelopmentController extends Controller { startDate: x.dateStart, endDate: x.dateEnd, isDate: true, + isEntry: false, developmentId: id, }) .then((x) => { @@ -2701,6 +2702,7 @@ export class DevelopmentController extends Controller { startDate: x.dateStart, endDate: x.dateEnd, isDate: true, + isEntry: false, developmentId: id, }) .then((x) => { From b95d59783b50ba3d30eb1540fcf26ab24d265eaa Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 16 Jul 2025 14:26:48 +0700 Subject: [PATCH 24/32] update --- src/controllers/DevelopmentController.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index 5aa9632..77986d2 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -2678,7 +2678,6 @@ export class DevelopmentController extends Controller { startDate: x.dateStart, endDate: x.dateEnd, isDate: true, - isEntry: false, developmentId: id, }) .then((x) => { @@ -2702,7 +2701,6 @@ export class DevelopmentController extends Controller { startDate: x.dateStart, endDate: x.dateEnd, isDate: true, - isEntry: false, developmentId: id, }) .then((x) => { From e78811dfd6bf5e903189964422180028d7afef6f Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 16 Jul 2025 15:10:37 +0700 Subject: [PATCH 25/32] #963 , #964 --- src/controllers/DevelopmentEmployeeHistoryController.ts | 1 + src/controllers/DevelopmentHistoryController.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/controllers/DevelopmentEmployeeHistoryController.ts b/src/controllers/DevelopmentEmployeeHistoryController.ts index 2b8054f..2fb81f3 100644 --- a/src/controllers/DevelopmentEmployeeHistoryController.ts +++ b/src/controllers/DevelopmentEmployeeHistoryController.ts @@ -403,6 +403,7 @@ export class DevelopmentEmployeeHistoryController extends Controller { 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: diff --git a/src/controllers/DevelopmentHistoryController.ts b/src/controllers/DevelopmentHistoryController.ts index 5ab0f55..edb65eb 100644 --- a/src/controllers/DevelopmentHistoryController.ts +++ b/src/controllers/DevelopmentHistoryController.ts @@ -390,6 +390,7 @@ export class DevelopmentOfficerHistoryController extends Controller { 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: From 06385990b56e691ea45e0652675d5996e8d38a2f Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 16 Jul 2025 16:36:14 +0700 Subject: [PATCH 26/32] #1635 --- src/controllers/DevelopmentController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index 77986d2..8bc84cf 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -1551,7 +1551,7 @@ export class DevelopmentController extends Controller { if (!development) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); } - Object.assign(development, { ...requestBody, developmentAddresss: [] }); + Object.assign(development, { ...requestBody}); development.lastUpdateUserId = request.user.sub; development.lastUpdateFullName = request.user.name; development.lastUpdatedAt = new Date(); From 9f21a4d49866b1e921c556ebdb59b15f4c132d85 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Thu, 17 Jul 2025 18:21:01 +0700 Subject: [PATCH 27/32] #1412 --- src/controllers/DevelopmentController.ts | 75 ++++++------------------ 1 file changed, 19 insertions(+), 56 deletions(-) diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index 8bc84cf..1bb0417 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -1946,6 +1946,9 @@ export class DevelopmentController extends Controller { developmentProjectTechniqueActuals: true, developmentEvaluations: true, developmentAddresss: true, + developmentRisks: true, + developmentHistorys: true, + developmentOthers: true, }, }); if (!development) { @@ -1959,92 +1962,46 @@ export class DevelopmentController extends Controller { const plannedGoalPosition = await this.plannedGoalPositionRepository.find({ where: { plannedGoalId: In(development.developmentPlannedGoals.map((x) => x.id)) }, }); - // addLogSequence(request, { - // action: "remove", - // status: "success", - // description: "Remove PlannedGoalPosition.", - // }); await this.plannedGoalPositionRepository.remove(plannedGoalPosition, { data: request }); } - // addLogSequence(request, { - // action: "remove", - // status: "success", - // description: "Remove ActualPeople.", - // }); await this.actualPeopleRepository.remove(development.developmentActualPeoples, { data: request, }); - // addLogSequence(request, { - // action: "remove", - // status: "success", - // description: "Remove PlannedPeople.", - // }); await this.plannedPeopleRepository.remove(development.developmentPlannedPeoples, { data: request, }); - // addLogSequence(request, { - // action: "remove", - // status: "success", - // description: "Remove ActualGoal.", - // }); await this.actualGoalRepository.remove(development.developmentActualGoals, { data: request }); - // addLogSequence(request, { - // action: "remove", - // status: "success", - // description: "Remove PlannedGoal.", - // }); await this.plannedGoalRepository.remove(development.developmentPlannedGoals, { data: request }); - // addLogSequence(request, { - // action: "remove", - // status: "success", - // description: "Remove DevelopmentProjectType.", - // }); await this.developmentProjectTypeRepository.remove(development.developmentProjectTypes, { data: request, }); - // addLogSequence(request, { - // action: "remove", - // status: "success", - // description: "Remove DevelopmentProjectTechniquePlanned.", - // }); await this.developmentProjectTechniquePlannedRepository.remove( development.developmentProjectTechniquePlanneds, { data: request, }, ); - // addLogSequence(request, { - // action: "remove", - // status: "success", - // description: "Remove DevelopmentProjectTechniqueActuals.", - // }); await this.developmentProjectTechniqueActualRepository.remove( development.developmentProjectTechniqueActuals, { data: request, }, ); - // addLogSequence(request, { - // action: "remove", - // status: "success", - // description: "Remove DevelopmentEvaluation.", - // }); await this.developmentEvaluationRepository.remove(development.developmentEvaluations, { data: request, }); - // addLogSequence(request, { - // action: "remove", - // status: "success", - // description: "Remove DevelopmentAddresss.", - // }); await this.developmentAddresssRepository.remove(development.developmentAddresss, { data: request, }); - // addLogSequence(request, { - // action: "remove", - // status: "success", - // description: "Remove Development.", - // }); + await this.developmentRiskRepository.remove(development.developmentRisks, { + data: request, + }); + await this.developmentHistoryRepository.remove(development.developmentHistorys, { + data: request, + }); + await this.developmentOtherRepository.remove(development.developmentOthers, { + data: request, + }); await this.developmentRepository.remove(development, { data: request }); return new HttpSuccess(); } @@ -2786,7 +2743,13 @@ export class DevelopmentController extends Controller { techniqueActuals.length > 0 && dev20Lists.some((item) => techniqueActuals.includes(item)); isDevelopment10 = techniqueActuals.length > 0 && dev10Lists.some((item) => techniqueActuals.includes(item)); - + + console.log("x.development?.developmentProjectTechniqueActuals",x.development?.developmentProjectTechniqueActuals); + console.log("techniqueActuals",techniqueActuals); + console.log("isDevelopment70",isDevelopment70); + console.log("isDevelopment20",isDevelopment20); + console.log("isDevelopment10",isDevelopment10); + if (x.type == "OFFICER") { await new CallAPI() .PostData(request, "/org/profile/development", { From 8c51bcc920c77a48f2a7500cb974577739836001 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Thu, 24 Jul 2025 13:41:09 +0700 Subject: [PATCH 28/32] delete log --- src/controllers/DevelopmentController.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index 1bb0417..0642d60 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -2743,12 +2743,6 @@ export class DevelopmentController extends Controller { techniqueActuals.length > 0 && dev20Lists.some((item) => techniqueActuals.includes(item)); isDevelopment10 = techniqueActuals.length > 0 && dev10Lists.some((item) => techniqueActuals.includes(item)); - - console.log("x.development?.developmentProjectTechniqueActuals",x.development?.developmentProjectTechniqueActuals); - console.log("techniqueActuals",techniqueActuals); - console.log("isDevelopment70",isDevelopment70); - console.log("isDevelopment20",isDevelopment20); - console.log("isDevelopment10",isDevelopment10); if (x.type == "OFFICER") { await new CallAPI() From 0f5b9401adc7c5d045a2c9114c5471b5542daaf6 Mon Sep 17 00:00:00 2001 From: kittapath-Jool Date: Fri, 1 Aug 2025 15:50:28 +0700 Subject: [PATCH 29/32] delete dna post --- .github/workflows/release.yaml | 72 +++++++++++++------------- src/entities/DevelopmentScholarship.ts | 2 +- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0d19c5a..6916881 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -67,40 +67,40 @@ jobs: docker compose pull docker compose up -d echo "${{ steps.gen_ver.outputs.image_ver }}"> success - - name: Notify Discord Success - if: success() - 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 Success + # if: success() + # 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() - 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 }} + # - name: Notify Discord Failure + # if: failure() + # 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 }} diff --git a/src/entities/DevelopmentScholarship.ts b/src/entities/DevelopmentScholarship.ts index cd1c614..24745ae 100644 --- a/src/entities/DevelopmentScholarship.ts +++ b/src/entities/DevelopmentScholarship.ts @@ -606,7 +606,7 @@ export class CreateDevelopmentScholarship { posExecutive: string | null; posLevelId: string | null; posTypeId: string | null; - guarantorRootDnaId: string | null; + guarantorRootDnaId?: string | null; guarantorRootId: string | null; guarantorRoot: string | null; guarantorOrg: string | null; From d93edbf97addd025eefbcd5f8a6d36eeca498720 Mon Sep 17 00:00:00 2001 From: kittapath-Jool Date: Fri, 1 Aug 2025 15:54:00 +0700 Subject: [PATCH 30/32] add noti --- .github/workflows/release.yaml | 72 +++++++++++++++++----------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6916881..0d19c5a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -67,40 +67,40 @@ jobs: docker compose pull docker compose up -d echo "${{ steps.gen_ver.outputs.image_ver }}"> success - # - name: Notify Discord Success - # if: success() - # 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 Success + if: success() + 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() - # 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 }} + - name: Notify Discord Failure + if: failure() + 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 }} From 217354f65319b344df0ee163d21364e6aaae136f Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 6 Aug 2025 10:53:06 +0700 Subject: [PATCH 31/32] =?UTF-8?q?api=20=E0=B8=A3=E0=B8=B2=E0=B8=A2?= =?UTF-8?q?=E0=B8=A5=E0=B8=B0=E0=B9=80=E0=B8=AD=E0=B8=B5=E0=B8=A2=E0=B8=94?= =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=9C?= =?UTF-8?q?=E0=B8=A5=E0=B8=87=E0=B8=B2=E0=B8=99=20=E0=B9=83=E0=B8=8A?= =?UTF-8?q?=E0=B9=89.o=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=87=E0=B8=B2?= =?UTF-8?q?=E0=B8=99=20=E0=B8=81.=E0=B8=9E.7/=E0=B8=81.=E0=B8=81.1=20#1642?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/PortfolioController.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/controllers/PortfolioController.ts b/src/controllers/PortfolioController.ts index 294b7f6..eecf28a 100644 --- a/src/controllers/PortfolioController.ts +++ b/src/controllers/PortfolioController.ts @@ -103,6 +103,32 @@ export class PortfolioController extends Controller { 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 ผลงาน * From 0f4b9778eeac59ee99e38c051c9b4d1fefd02533 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Mon, 18 Aug 2025 16:36:23 +0700 Subject: [PATCH 32/32] update search --- src/controllers/DevelopmentEmployeeHistoryController.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/controllers/DevelopmentEmployeeHistoryController.ts b/src/controllers/DevelopmentEmployeeHistoryController.ts index 2fb81f3..007d978 100644 --- a/src/controllers/DevelopmentEmployeeHistoryController.ts +++ b/src/controllers/DevelopmentEmployeeHistoryController.ts @@ -276,6 +276,14 @@ export class DevelopmentEmployeeHistoryController extends Controller { 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"