From 7eeaf85750311873f20245c33a3c357ef991c4e4 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 21 May 2025 15:02:17 +0700 Subject: [PATCH 1/2] test --- src/controllers/EvaluationController.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index ba9c270..5457944 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -254,16 +254,18 @@ export class EvaluationController { .createQueryBuilder("evaluation") .andWhere( new Brackets((qb) => { - qb.andWhere( + if ( body.status == undefined || - body.status == null || - body.status.every((s) => s === "ALL") - ? "1=1" - : `evaluation.step In (:status)`, - { + body.status == null || + body.status.every((s) => s === "ALL") + ) { + qb.andWhere("1=1"); + } else { + qb.andWhere("evaluation.step IN (:...status)", { status: body.status, - }, - ).andWhere("evaluation.createdUserId = :createdUserId", { + }); + } + qb.andWhere("evaluation.createdUserId = :createdUserId", { createdUserId: request.user.sub, }); }), @@ -919,13 +921,15 @@ export class EvaluationController { ], }); if (!evaluation) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "not found."); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } return new HttpSuccess(evaluation); } catch (error: any) { if (error instanceof HttpError) { throw error; - } else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error); + } + console.error("Unexpected error:", error); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถดําเนินการได้"); } } From 2178caa0c1b12f54fe962184f2419c279915665c Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 21 May 2025 15:46:36 +0700 Subject: [PATCH 2/2] fix --- src/entities/Evaluation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entities/Evaluation.ts b/src/entities/Evaluation.ts index e815f37..65c5baa 100644 --- a/src/entities/Evaluation.ts +++ b/src/entities/Evaluation.ts @@ -596,7 +596,7 @@ export class CreateEvaluationExpertise { author?: string | null; @Column() - subject?: string | null; + subject?: string[] | null; @Column() commanderFullname?: string | null;