From e2f3234e2d31edb94e68d88ddc7d505fea8c1c5d Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 29 Jan 2025 10:59:58 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7=E0=B8=B1?= =?UTF-8?q?=E0=B8=95=E0=B8=B4=20reject?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KpiUserEvaluationController.ts | 70 ++++++++++++++++++- src/entities/kpiUserRejectAgreement.ts | 22 ++++++ src/entities/kpiUserRejectResult.ts | 22 ++++++ .../1738123092759-Updateevaaddreject1.ts | 24 +++++++ 4 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 src/migration/1738123092759-Updateevaaddreject1.ts diff --git a/src/controllers/KpiUserEvaluationController.ts b/src/controllers/KpiUserEvaluationController.ts index db667d5..7db2847 100644 --- a/src/controllers/KpiUserEvaluationController.ts +++ b/src/controllers/KpiUserEvaluationController.ts @@ -1048,7 +1048,7 @@ export class KpiUserEvaluationController extends Controller { @Put("reject-agreement/{id}") async updateKpiUserStatusRejectAgreementEvaluation( @Path() id: string, - @Body() requestBody: { reason: string }, + @Body() requestBody: { reason: string; actor: string }, @Request() request: RequestWithUser, ) { const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({ @@ -1081,7 +1081,11 @@ export class KpiUserEvaluationController extends Controller { kpiUserEvaluation.lastUpdateFullName = request.user.name; kpiUserEvaluation.lastUpdatedAt = new Date(); let kpiReject = { + kpiUserEvaluationId: kpiUserEvaluation.id, reason: requestBody.reason, + actor: requestBody.actor, + fullname: `${kpiUserEvaluation.prefixEvaluator}${kpiUserEvaluation.firstNameEvaluator} ${kpiUserEvaluation.lastNameEvaluator}`, + profileId: kpiUserEvaluation.evaluatorId, createdUserId: request.user.sub, createdFullName: request.user.name, lastUpdateUserId: request.user.sub, @@ -1105,7 +1109,7 @@ export class KpiUserEvaluationController extends Controller { @Put("reject-result/{id}") async updateKpiUserStatusRejectResultEvaluation( @Path() id: string, - @Body() requestBody: { reason: string }, + @Body() requestBody: { reason: string; actor: string }, @Request() request: RequestWithUser, ) { const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({ @@ -1131,12 +1135,19 @@ export class KpiUserEvaluationController extends Controller { .catch(() => {}); const before = structuredClone(kpiUserEvaluation); kpiUserEvaluation.evaluationStatus = "EVALUATING_EVALUATOR"; + let _null: any = null; + kpiUserEvaluation.isReasonCommander = _null; + kpiUserEvaluation.reasonCommander = _null; kpiUserEvaluation.reasonReject = requestBody.reason; kpiUserEvaluation.lastUpdateUserId = request.user.sub; kpiUserEvaluation.lastUpdateFullName = request.user.name; kpiUserEvaluation.lastUpdatedAt = new Date(); let kpiReject = { + kpiUserEvaluationId: kpiUserEvaluation.id, reason: requestBody.reason, + actor: requestBody.actor, + fullname: `${kpiUserEvaluation.prefixEvaluator}${kpiUserEvaluation.firstNameEvaluator} ${kpiUserEvaluation.lastNameEvaluator}`, + profileId: kpiUserEvaluation.evaluatorId, createdUserId: request.user.sub, createdFullName: request.user.name, lastUpdateUserId: request.user.sub, @@ -1150,6 +1161,61 @@ export class KpiUserEvaluationController extends Controller { return new HttpSuccess(kpiUserEvaluation.id); } + /** + * API แก้ไขสถานะประเมิน (USER) + * + * @summary แก้ไขคนประเมิน (USER) + * + * @param {string} id Guid, *Id คนประเมิน (USER) + */ + @Get("reject-agreement/{id}") + async listKpiUserStatusRejectAgreementEvaluation( + @Path() id: string, + @Request() request: RequestWithUser, + ) { + const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({ + where: { id: id }, + relations: ["kpiUserRejectAgreements"], + order: { kpiUserRejectAgreements: { createdAt: "ASC" } }, + }); + if (!kpiUserEvaluation) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้", + ); + } + kpiUserEvaluation.kpiUserRejectAgreements; + return new HttpSuccess(kpiUserEvaluation.kpiUserRejectAgreements); + } + + /** + * API แก้ไขสถานะประเมิน (USER) + * + * @summary แก้ไขคนประเมิน (USER) + * + * @param {string} id Guid, *Id คนประเมิน (USER) + */ + @Get("reject-result/{id}") + async listKpiUserStatusRejectResultEvaluation( + @Path() id: string, + @Body() requestBody: { reason: string }, + @Request() request: RequestWithUser, + ) { + const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({ + where: { id: id }, + relations: ["kpiUserRejectResults"], + order: { kpiUserRejectResults: { createdAt: "ASC" } }, + }); + if (!kpiUserEvaluation) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้", + ); + } + kpiUserEvaluation.kpiUserRejectResults; + return new HttpSuccess(kpiUserEvaluation.kpiUserRejectResults); + } + /** * API รายละเอียดรายการประเมินผลการปฏิบัติราชการระดับบุคคล (USER) * diff --git a/src/entities/kpiUserRejectAgreement.ts b/src/entities/kpiUserRejectAgreement.ts index 642e796..8f31ce7 100644 --- a/src/entities/kpiUserRejectAgreement.ts +++ b/src/entities/kpiUserRejectAgreement.ts @@ -4,6 +4,28 @@ import { KpiUserEvaluation } from "./kpiUserEvaluation"; @Entity("kpiUserRejectAgreement") export class KpiUserRejectAgreement extends EntityBase { + @Column({ + nullable: true, + comment: "ชื่อคนรับการประเมิน", + default: null, + }) + fullname: string; + + @Column({ + nullable: true, + length: 40, + comment: "ไอดีโปรไฟล์", + default: null, + }) + profileId: string; + + @Column({ + nullable: true, + comment: "ผู้ดำเนิน", + default: null, + }) + actor: string; + @Column({ nullable: true, comment: "หมายเหตุ", diff --git a/src/entities/kpiUserRejectResult.ts b/src/entities/kpiUserRejectResult.ts index 5b48779..5cc5d52 100644 --- a/src/entities/kpiUserRejectResult.ts +++ b/src/entities/kpiUserRejectResult.ts @@ -4,6 +4,28 @@ import { KpiUserEvaluation } from "./kpiUserEvaluation"; @Entity("kpiUserRejectResult") export class KpiUserRejectResult extends EntityBase { + @Column({ + nullable: true, + comment: "ชื่อคนรับการประเมิน", + default: null, + }) + fullname: string; + + @Column({ + nullable: true, + length: 40, + comment: "ไอดีโปรไฟล์", + default: null, + }) + profileId: string; + + @Column({ + nullable: true, + comment: "ผู้ดำเนิน", + default: null, + }) + actor: string; + @Column({ nullable: true, comment: "หมายเหตุ", diff --git a/src/migration/1738123092759-Updateevaaddreject1.ts b/src/migration/1738123092759-Updateevaaddreject1.ts new file mode 100644 index 0000000..76cbb37 --- /dev/null +++ b/src/migration/1738123092759-Updateevaaddreject1.ts @@ -0,0 +1,24 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class Updateevaaddreject11738123092759 implements MigrationInterface { + name = 'Updateevaaddreject11738123092759' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`kpiUserRejectAgreement\` ADD \`fullname\` varchar(255) NULL COMMENT 'ชื่อคนรับการประเมิน'`); + await queryRunner.query(`ALTER TABLE \`kpiUserRejectAgreement\` ADD \`profileId\` varchar(40) NULL COMMENT 'ไอดีโปรไฟล์'`); + await queryRunner.query(`ALTER TABLE \`kpiUserRejectAgreement\` ADD \`actor\` varchar(255) NULL COMMENT 'ผู้ดำเนิน'`); + await queryRunner.query(`ALTER TABLE \`kpiUserRejectResult\` ADD \`fullname\` varchar(255) NULL COMMENT 'ชื่อคนรับการประเมิน'`); + await queryRunner.query(`ALTER TABLE \`kpiUserRejectResult\` ADD \`profileId\` varchar(40) NULL COMMENT 'ไอดีโปรไฟล์'`); + await queryRunner.query(`ALTER TABLE \`kpiUserRejectResult\` ADD \`actor\` varchar(255) NULL COMMENT 'ผู้ดำเนิน'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`kpiUserRejectResult\` DROP COLUMN \`actor\``); + await queryRunner.query(`ALTER TABLE \`kpiUserRejectResult\` DROP COLUMN \`profileId\``); + await queryRunner.query(`ALTER TABLE \`kpiUserRejectResult\` DROP COLUMN \`fullname\``); + await queryRunner.query(`ALTER TABLE \`kpiUserRejectAgreement\` DROP COLUMN \`actor\``); + await queryRunner.query(`ALTER TABLE \`kpiUserRejectAgreement\` DROP COLUMN \`profileId\``); + await queryRunner.query(`ALTER TABLE \`kpiUserRejectAgreement\` DROP COLUMN \`fullname\``); + } + +}