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, "ไม่สามารถดําเนินการได้"); } } 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;