From 5d7c0e7ca52b418782ac8faf6fc374fd71f172df Mon Sep 17 00:00:00 2001 From: harid Date: Tue, 16 Dec 2025 14:14:39 +0700 Subject: [PATCH] fix bug #2071 --- .../DevelopmentScholarshipController.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/controllers/DevelopmentScholarshipController.ts b/src/controllers/DevelopmentScholarshipController.ts index 57ec84c..38bcda9 100644 --- a/src/controllers/DevelopmentScholarshipController.ts +++ b/src/controllers/DevelopmentScholarshipController.ts @@ -170,20 +170,27 @@ export class DevelopmentScholarshipController extends Controller { _data = x; }) .catch((x) => {}); - + let _status:string = ""; if (keyword && ["กำลังศึกษา", "เรียนไม่จบ", "เรียนจบ"].includes(keyword.trim())) { const mapStatus: Record = { "กำลังศึกษา": "PENDING", "เรียนไม่จบ": "NOTGRADUATE", "เรียนจบ": "GRADUATE", }; - keyword = mapStatus[keyword.trim()]; + _status = mapStatus[keyword.trim()]; + keyword = ""; } let query = await AppDataSource.getRepository(DevelopmentScholarship) .createQueryBuilder("developmentScholarship") .leftJoinAndSelect("developmentScholarship.posLevel", "posLevel") .leftJoinAndSelect("developmentScholarship.posType", "posType") + .andWhere( + _status != "" && keyword == "" + ? "developmentScholarship.status = :status" + : "1=1", + { status: _status }, + ) .andWhere( year !== 0 && year != null && year != undefined ? "developmentScholarship.scholarshipYear = :scholarshipYear" @@ -230,14 +237,6 @@ export class DevelopmentScholarshipController extends Controller { keyword: `%${keyword}%`, }, ) - .orWhere( - keyword != null && keyword != "" - ? "developmentScholarship.status LIKE :keyword" - : "1=1", - { - keyword: `${keyword}`, - }, - ) .orWhere( keyword != null && keyword != "" ? "posType.posTypeName LIKE :keyword" : "1=1", {