diff --git a/src/controllers/DevelopmentScholarshipController.ts b/src/controllers/DevelopmentScholarshipController.ts index 5c441a0..295dc9c 100644 --- a/src/controllers/DevelopmentScholarshipController.ts +++ b/src/controllers/DevelopmentScholarshipController.ts @@ -158,21 +158,20 @@ export class DevelopmentScholarshipController extends Controller { ) .andWhere( scholarshipType != null && scholarshipType != undefined - ? - "developmentScholarship.scholarshipType = :scholarshipType" - : "1=1", - { scholarshipType: scholarshipType } - ) + ? "developmentScholarship.scholarshipType = :scholarshipType" + : "1=1", + { scholarshipType: scholarshipType }, + ) .andWhere( - new Brackets((qb) => { - qb.where( - keyword != null && keyword != "" - ? `CONCAT(developmentScholarship.prefix, developmentScholarship.firstName," ",developmentScholarship.lastName) like '%${keyword}%'` - : "1=1", - { - keyword: `%${keyword}%`, - }, - ) + new Brackets((qb) => { + qb.where( + keyword != null && keyword != "" + ? `CONCAT(developmentScholarship.prefix, developmentScholarship.firstName," ",developmentScholarship.lastName) like '%${keyword}%'` + : "1=1", + { + keyword: `%${keyword}%`, + }, + ) .orWhere( keyword != null && keyword != "" ? "developmentScholarship.position LIKE :keyword" @@ -230,7 +229,7 @@ export class DevelopmentScholarshipController extends Controller { @Get("{id}") async GetDevelopemtScholarshipById(@Path() id: string) { const getDevelopment = await this.developmentScholarshipRepository.findOne({ - relations: ["posLevel", "posType","posLevelguarantor","posTypeguarantor"], + relations: ["posLevel", "posType", "posLevelguarantor", "posTypeguarantor"], where: { id: id }, }); if (!getDevelopment) { @@ -245,27 +244,43 @@ export class DevelopmentScholarshipController extends Controller { position: getDevelopment.position ? getDevelopment.position : null, posExecutive: getDevelopment.posExecutive ? getDevelopment.posExecutive : null, posLevelId: getDevelopment.posLevelId ? getDevelopment.posLevelId : null, - posLevelName: getDevelopment.posLevel?.posLevelName ? getDevelopment.posLevel?.posLevelName : null, + posLevelName: getDevelopment.posLevel?.posLevelName + ? getDevelopment.posLevel?.posLevelName + : null, posTypeId: getDevelopment.posTypeId ? getDevelopment.posTypeId : null, posTypeName: getDevelopment.posType?.posTypeName ? getDevelopment.posType?.posTypeName : null, guarantorRank: getDevelopment.guarantorRank ? getDevelopment.guarantorRank : null, guarantorPrefix: getDevelopment.guarantorPrefix ? getDevelopment.guarantorPrefix : null, - guarantorFirstName: getDevelopment.guarantorFirstName ? getDevelopment.guarantorFirstName : null, + guarantorFirstName: getDevelopment.guarantorFirstName + ? getDevelopment.guarantorFirstName + : null, guarantorLastName: getDevelopment.guarantorLastName ? getDevelopment.guarantorLastName : null, - guarantorCitizenId: getDevelopment.guarantorCitizenId ? getDevelopment.guarantorCitizenId : null, + guarantorCitizenId: getDevelopment.guarantorCitizenId + ? getDevelopment.guarantorCitizenId + : null, guarantorPosition: getDevelopment.guarantorPosition ? getDevelopment.guarantorPosition : null, - guarantorPosExecutive: getDevelopment.guarantorPosExecutive ? getDevelopment.guarantorPosExecutive : null, - posLevelguarantorId: getDevelopment.posLevelguarantorId ? getDevelopment.posLevelguarantorId : null, - posLevelguarantorName: getDevelopment.posLevelguarantor?.posLevelName ? getDevelopment.posLevelguarantor?.posLevelName : null, - posTypeguarantorId: getDevelopment.posTypeguarantorId ? getDevelopment.posTypeguarantorId : null, - posTypeguarantorName: getDevelopment.posTypeguarantor?.posTypeName ? getDevelopment.posTypeguarantor?.posTypeName : null, + guarantorPosExecutive: getDevelopment.guarantorPosExecutive + ? getDevelopment.guarantorPosExecutive + : null, + posLevelguarantorId: getDevelopment.posLevelguarantorId + ? getDevelopment.posLevelguarantorId + : null, + posLevelguarantorName: getDevelopment.posLevelguarantor?.posLevelName + ? getDevelopment.posLevelguarantor?.posLevelName + : null, + posTypeguarantorId: getDevelopment.posTypeguarantorId + ? getDevelopment.posTypeguarantorId + : null, + posTypeguarantorName: getDevelopment.posTypeguarantor?.posTypeName + ? getDevelopment.posTypeguarantor?.posTypeName + : null, scholarshipYear: getDevelopment.scholarshipYear ? getDevelopment.scholarshipYear : null, budgetSource: getDevelopment.budgetSource ? getDevelopment.budgetSource : null, budgetApprove: getDevelopment.budgetApprove ? getDevelopment.budgetApprove : null, bookNo: getDevelopment.bookNo ? getDevelopment.bookNo : null, bookNoDate: getDevelopment.bookNoDate ? getDevelopment.bookNoDate : null, bookApproveDate: getDevelopment.bookApproveDate ? getDevelopment.bookApproveDate : null, - useOfficialTime: getDevelopment.useOfficialTime ? getDevelopment.useOfficialTime : null, + useOfficialTime: getDevelopment.useOfficialTime ? getDevelopment.useOfficialTime : false, changeDetail: getDevelopment.changeDetail ? getDevelopment.changeDetail : null, scholarshipType: getDevelopment.scholarshipType ? getDevelopment.scholarshipType : null, fundType: getDevelopment.fundType ? getDevelopment.fundType : null, @@ -278,7 +293,9 @@ export class DevelopmentScholarshipController extends Controller { course: getDevelopment.course ? getDevelopment.course : null, field: getDevelopment.field ? getDevelopment.field : null, faculty: getDevelopment.faculty ? getDevelopment.faculty : null, - educationalInstitution: getDevelopment.educationalInstitution ? getDevelopment.educationalInstitution : null, + educationalInstitution: getDevelopment.educationalInstitution + ? getDevelopment.educationalInstitution + : null, startDate: getDevelopment.startDate ? getDevelopment.startDate : null, endDate: getDevelopment.endDate ? getDevelopment.endDate : null, studyPlace: getDevelopment.studyPlace ? getDevelopment.studyPlace : null, @@ -287,9 +304,13 @@ export class DevelopmentScholarshipController extends Controller { studyEndDate: getDevelopment.studyEndDate ? getDevelopment.studyEndDate : null, studyCountry: getDevelopment.studyCountry ? getDevelopment.studyCountry : null, studyAbroadTopic: getDevelopment.studyAbroadTopic ? getDevelopment.studyAbroadTopic : null, - studyAbroadStartDate: getDevelopment.studyAbroadStartDate ? getDevelopment.studyAbroadStartDate : null, - studyAbroadEndDate: getDevelopment.studyAbroadEndDate ? getDevelopment.studyAbroadEndDate : null, - totalPeriod: getDevelopment.totalPeriod ? getDevelopment.totalPeriod : null + studyAbroadStartDate: getDevelopment.studyAbroadStartDate + ? getDevelopment.studyAbroadStartDate + : null, + studyAbroadEndDate: getDevelopment.studyAbroadEndDate + ? getDevelopment.studyAbroadEndDate + : null, + totalPeriod: getDevelopment.totalPeriod ? getDevelopment.totalPeriod : null, }; return new HttpSuccess(formattedData); }