From ae87b678d1a188d99d91e2205465a8483e24cd35 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 26 Jun 2024 12:41:38 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=AB=E0=B8=A1=E0=B8=B2=E0=B8=A2=E0=B9=80?= =?UTF-8?q?=E0=B8=AB=E0=B8=95=E0=B8=B8=20=E0=B8=9C=E0=B8=B9=E0=B9=89?= =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B9=80=E0=B8=A1=E0=B8=B4=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KpiUserEvaluationController.ts | 203 ++++++++++++++++++ src/entities/kpiUserEvaluation.ts | 69 ++++++ ...pdate_table_kpiUserEvalution_add_reason.ts | 30 +++ 3 files changed, 302 insertions(+) create mode 100644 src/migration/1719376307198-update_table_kpiUserEvalution_add_reason.ts diff --git a/src/controllers/KpiUserEvaluationController.ts b/src/controllers/KpiUserEvaluationController.ts index 97b7832..fd076dd 100644 --- a/src/controllers/KpiUserEvaluationController.ts +++ b/src/controllers/KpiUserEvaluationController.ts @@ -987,4 +987,207 @@ export class KpiUserEvaluationController extends Controller { return new HttpSuccess(); } + + /** + * + * + * @param {string} id Guid, *Id คนประเมิน (USER) + */ + @Get("open/{id}") + async openKpiUserEvaluation( + @Path() id: string, + @Request() request: { user: Record }, + ) { + const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({ + where: { id: id }, + }); + if (!kpiUserEvaluation) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้", + ); + } + kpiUserEvaluation.isOpen = true; + kpiUserEvaluation.lastUpdateUserId = request.user.sub; + kpiUserEvaluation.lastUpdateFullName = request.user.name; + await this.kpiUserEvalutionRepository.save(kpiUserEvaluation); + return new HttpSuccess(kpiUserEvaluation.id); + } + + /** + * API แก้ไขสรุปผลการประเมิน (USER) + * + * @summary แก้ไขสรุปผลการประเมิน (USER) + * + * @param {string} id Guid, *Id คนประเมิน (USER) + */ + @Put("reason/user/{id}") + async updateReasonKpiUserEvaluation( + @Path() id: string, + @Body() + requestBody: { + topicEvaluator?: string | null; + developEvaluator?: string | null; + timeEvaluator?: string | null; + reasonEvaluator?: string | null; + }, + @Request() request: { user: Record }, + ) { + const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({ + where: { id: id }, + }); + if (!kpiUserEvaluation) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้", + ); + } + const _null: any = null; + kpiUserEvaluation.topicEvaluator = + requestBody.topicEvaluator == null ? _null : requestBody.topicEvaluator; + kpiUserEvaluation.developEvaluator = + requestBody.developEvaluator == null ? _null : requestBody.developEvaluator; + kpiUserEvaluation.timeEvaluator = + requestBody.timeEvaluator == null ? _null : requestBody.timeEvaluator; + kpiUserEvaluation.reasonEvaluator = + requestBody.reasonEvaluator == null ? _null : requestBody.reasonEvaluator; + kpiUserEvaluation.lastUpdateUserId = request.user.sub; + kpiUserEvaluation.lastUpdateFullName = request.user.name; + await this.kpiUserEvalutionRepository.save(kpiUserEvaluation); + return new HttpSuccess(kpiUserEvaluation.id); + } + + /** + * API แก้ไขสรุปผลการประเมินผู้บังคับบัญชาเหนือขึ้นไป (USER) + * + * @summary แก้ไขสรุปผลการประเมินผู้บังคับบัญชาเหนือขึ้นไป (USER) + * + * @param {string} id Guid, *Id คนประเมิน (USER) + */ + @Put("reason/commander/{id}") + async updateReasonKpiCommanderEvaluation( + @Path() id: string, + @Body() + requestBody: { + isReason: boolean; + reason?: string | null; + }, + @Request() request: { user: Record }, + ) { + const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({ + where: { id: id }, + }); + if (!kpiUserEvaluation) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้", + ); + } + const _null: any = null; + kpiUserEvaluation.isReasonCommander = requestBody.isReason; + kpiUserEvaluation.reasonCommander = requestBody.reason == null ? _null : requestBody.reason; + kpiUserEvaluation.lastUpdateUserId = request.user.sub; + kpiUserEvaluation.lastUpdateFullName = request.user.name; + await this.kpiUserEvalutionRepository.save(kpiUserEvaluation); + return new HttpSuccess(kpiUserEvaluation.id); + } + + /** + * API แก้ไขสรุปผลการประเมินผู้บังคับบัญชาเหนือขึ้นไปอีกหนึ่งขั้น (USER) + * + * @summary แก้ไขสรุปผลการประเมินผู้บังคับบัญชาเหนือขึ้นไปอีกหนึ่งขั้น (USER) + * + * @param {string} id Guid, *Id คนประเมิน (USER) + */ + @Put("reason/commanderHigh/{id}") + async updateReasonKpiCommanderHighEvaluation( + @Path() id: string, + @Body() + requestBody: { + isReason: boolean; + reason?: string | null; + }, + @Request() request: { user: Record }, + ) { + const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({ + where: { id: id }, + }); + if (!kpiUserEvaluation) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้", + ); + } + const _null: any = null; + kpiUserEvaluation.isReasonCommanderHigh = requestBody.isReason; + kpiUserEvaluation.reasonCommanderHigh = requestBody.reason == null ? _null : requestBody.reason; + kpiUserEvaluation.lastUpdateUserId = request.user.sub; + kpiUserEvaluation.lastUpdateFullName = request.user.name; + await this.kpiUserEvalutionRepository.save(kpiUserEvaluation); + return new HttpSuccess(kpiUserEvaluation.id); + } + + /** + * API รายละเอียดสรุปผลการประเมิน (USER) + * + * @summary รายละเอียดสรุปผลการประเมิน (USER) + * + * @param {string} id Guid, *Id คนประเมิน (USER) + */ + @Get("reason/{id}") + async getReasonKpiEvaluation( + @Path() id: string, + @Request() request: { user: Record }, + ) { + const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({ + where: { id: id }, + select: [ + "topicEvaluator", + "developEvaluator", + "timeEvaluator", + "reasonEvaluator", + "isReasonCommander", + "reasonCommander", + "isReasonCommanderHigh", + "reasonCommanderHigh", + "isOpen", + ], + }); + if (!kpiUserEvaluation) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้", + ); + } + return new HttpSuccess(kpiUserEvaluation); + } + + /** + * API รายละเอียดสรุปผลการประเมิน (USER) + * + * @summary รายละเอียดสรุปผลการประเมิน (USER) + * + * @param {string} id Guid, *Id คนประเมิน (USER) + */ + @Get("summary/{id}") + async getSummaryKpiEvaluation( + @Path() id: string, + @Request() request: { user: Record }, + ) { + const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({ + where: { id: id }, + select: ["id", "evaluationStatus", "lastUpdateUserId", "lastUpdateFullName"], + }); + if (!kpiUserEvaluation) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้", + ); + } + kpiUserEvaluation.evaluationStatus = "SUMMARY"; + kpiUserEvaluation.lastUpdateUserId = request.user.sub; + kpiUserEvaluation.lastUpdateFullName = request.user.name; + await this.kpiUserEvalutionRepository.save(kpiUserEvaluation); + return new HttpSuccess(kpiUserEvaluation); + } } diff --git a/src/entities/kpiUserEvaluation.ts b/src/entities/kpiUserEvaluation.ts index bf2c490..53bd0bd 100644 --- a/src/entities/kpiUserEvaluation.ts +++ b/src/entities/kpiUserEvaluation.ts @@ -188,6 +188,75 @@ export class KpiUserEvaluation extends EntityBase { }) summaryPoint: number; + @Column({ + nullable: true, + comment: "ชื่อเรื่อง/เนื้อหา/หัวข้อการพัฒนา", + length: 255, + default: null, + }) + topicEvaluator: string; + + @Column({ + nullable: true, + comment: "วิธีการพัฒนา", + length: 255, + default: null, + }) + developEvaluator: string; + + @Column({ + nullable: true, + comment: "ช่วงเวลาการพัฒนา", + length: 255, + default: null, + }) + timeEvaluator: string; + + @Column({ + nullable: true, + comment: "ความเห็นของผู้ประเมิน", + length: 255, + default: null, + }) + reasonEvaluator: string; + + @Column({ + nullable: true, + comment: "หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไป", + default: false, + }) + isReasonCommander: boolean; + + @Column({ + nullable: true, + comment: "หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไป", + length: 255, + default: null, + }) + reasonCommander: string; + + @Column({ + nullable: true, + comment: "หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง", + default: false, + }) + isReasonCommanderHigh: boolean; + + @Column({ + nullable: true, + comment: "หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง", + length: 255, + default: null, + }) + reasonCommanderHigh: string; + + @Column({ + nullable: true, + comment: "การรับทราบผลการประเมิน", + default: false, + }) + isOpen: boolean; + @Column({ nullable: true, length: 40, diff --git a/src/migration/1719376307198-update_table_kpiUserEvalution_add_reason.ts b/src/migration/1719376307198-update_table_kpiUserEvalution_add_reason.ts new file mode 100644 index 0000000..d2b2c2a --- /dev/null +++ b/src/migration/1719376307198-update_table_kpiUserEvalution_add_reason.ts @@ -0,0 +1,30 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableKpiUserEvalutionAddReason1719376307198 implements MigrationInterface { + name = 'UpdateTableKpiUserEvalutionAddReason1719376307198' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`topicEvaluator\` varchar(255) NULL COMMENT 'ชื่อเรื่อง/เนื้อหา/หัวข้อการพัฒนา'`); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`developEvaluator\` varchar(255) NULL COMMENT 'วิธีการพัฒนา'`); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`timeEvaluator\` varchar(255) NULL COMMENT 'ช่วงเวลาการพัฒนา'`); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`reasonEvaluator\` varchar(255) NULL COMMENT 'ความเห็นของผู้ประเมิน'`); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`isReasonCommander\` tinyint NULL COMMENT 'หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไป' DEFAULT 0`); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`reasonCommander\` varchar(255) NULL COMMENT 'หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไป'`); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`isReasonCommanderHigh\` tinyint NULL COMMENT 'หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง' DEFAULT 0`); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`reasonCommanderHigh\` varchar(255) NULL COMMENT 'หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง'`); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`isOpen\` tinyint NULL COMMENT 'การรับทราบผลการประเมิน' DEFAULT 0`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`isOpen\``); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`reasonCommanderHigh\``); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`isReasonCommanderHigh\``); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`reasonCommander\``); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`isReasonCommander\``); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`reasonEvaluator\``); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`timeEvaluator\``); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`developEvaluator\``); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`topicEvaluator\``); + } + +}