diff --git a/src/controllers/ProfileAbilityController.ts b/src/controllers/ProfileAbilityController.ts index a49e9130..30e2b683 100644 --- a/src/controllers/ProfileAbilityController.ts +++ b/src/controllers/ProfileAbilityController.ts @@ -79,7 +79,6 @@ export class ProfileAbilityController extends Controller { return new HttpSuccess(getProfileAbilityId); } - @Get("history/{abilityId}") @Example({ status: 200, @@ -192,7 +191,7 @@ export class ProfileAbilityController extends Controller { const result = await this.profileAbilityRepo.delete({ id: abilityId }); - if (result.affected && result.affected <= 0) + if (result.affected == undefined || result.affected <= 0) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); return new HttpSuccess(); diff --git a/src/controllers/ProfileAssessmentsController.ts b/src/controllers/ProfileAssessmentsController.ts index 5b008045..dfbecd3c 100644 --- a/src/controllers/ProfileAssessmentsController.ts +++ b/src/controllers/ProfileAssessmentsController.ts @@ -203,7 +203,7 @@ export class ProfileAssessmentsController extends Controller { const result = await this.profileAssessmentsRepository.delete({ id: assessmentId }); - if (result.affected && result.affected <= 0) + if (result.affected == undefined || result.affected <= 0) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); return new HttpSuccess(); diff --git a/src/controllers/ProfileChangeNameController.ts b/src/controllers/ProfileChangeNameController.ts index 8ddf8a86..a120052b 100644 --- a/src/controllers/ProfileChangeNameController.ts +++ b/src/controllers/ProfileChangeNameController.ts @@ -201,7 +201,7 @@ export class ProfileChangeNameController extends Controller { const result = await this.changeNameRepository.delete({ id: changeNameId }); - if (result.affected && result.affected <= 0) { + if (result.affected == undefined || result.affected <= 0) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index b7d32a98..fcc66d6e 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -835,7 +835,7 @@ export class ProfileController extends Controller { async deleteProfile(@Path() id: string) { const result = await this.profileRepo.delete({ id }); - if (result.affected && result.affected <= 0) { + if (result.affected == undefined || result.affected <= 0) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } diff --git a/src/controllers/ProfileDisciplineController.ts b/src/controllers/ProfileDisciplineController.ts index 47cd35ed..8a7780d7 100644 --- a/src/controllers/ProfileDisciplineController.ts +++ b/src/controllers/ProfileDisciplineController.ts @@ -184,7 +184,7 @@ export class ProfileDisciplineController extends Controller { const result = await this.disciplineRepository.delete({ id: disciplineId }); - if (result.affected && result.affected <= 0) { + if (result.affected == undefined || result.affected <= 0) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } diff --git a/src/controllers/ProfileDutyController.ts b/src/controllers/ProfileDutyController.ts index bbea6c69..dc70e062 100644 --- a/src/controllers/ProfileDutyController.ts +++ b/src/controllers/ProfileDutyController.ts @@ -185,7 +185,7 @@ export class ProfileDutyController extends Controller { const result = await this.dutyRepository.delete({ id: dutyId }); - if (result.affected && result.affected <= 0) { + if (result.affected == undefined || result.affected <= 0) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } diff --git a/src/controllers/ProfileEducationsController.ts b/src/controllers/ProfileEducationsController.ts index 358cf6fa..4a0f1332 100644 --- a/src/controllers/ProfileEducationsController.ts +++ b/src/controllers/ProfileEducationsController.ts @@ -239,7 +239,7 @@ export class ProfileEducationsController extends Controller { const result = await this.profileEducationRepo.delete({ id: educationId }); - if (result.affected && result.affected <= 0) + if (result.affected == undefined || result.affected <= 0) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); return new HttpSuccess(); diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 039b5595..b716b39a 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -52,10 +52,10 @@ import { OrgChild2 } from "../entities/OrgChild2"; import { OrgChild3 } from "../entities/OrgChild3"; import { OrgChild4 } from "../entities/OrgChild4"; import { ProfileEmployeeInformationHistory } from "../entities/ProfileEmployeeInformationHistory"; -import { - ProfileEmployeeEmployment, +import { + ProfileEmployeeEmployment, CreateEmploymentProfileEmployee, - UpdateEmploymentProfileEmployee + UpdateEmploymentProfileEmployee, } from "../entities/ProfileEmployeeEmployment"; import { ProfileEmployeeEmploymentHistory } from "../entities/ProfileEmployeeEmploymentHistory"; @@ -90,9 +90,13 @@ export class ProfileEmployeeController extends Controller { private child2Repository = AppDataSource.getRepository(OrgChild2); private child3Repository = AppDataSource.getRepository(OrgChild3); private child4Repository = AppDataSource.getRepository(OrgChild4); - private informationHistoryRepository = AppDataSource.getRepository(ProfileEmployeeInformationHistory); - private employmentRepository = AppDataSource.getRepository(ProfileEmployeeEmployment); - private employmentHistoryRepository = AppDataSource.getRepository(ProfileEmployeeEmploymentHistory); + private informationHistoryRepository = AppDataSource.getRepository( + ProfileEmployeeInformationHistory, + ); + private employmentRepository = AppDataSource.getRepository(ProfileEmployeeEmployment); + private employmentHistoryRepository = AppDataSource.getRepository( + ProfileEmployeeEmploymentHistory, + ); /** * report ประวัติแบบย่อ ลูกจ้าง @@ -610,7 +614,7 @@ export class ProfileEmployeeController extends Controller { async deleteProfile(@Path() id: string) { const result = await this.profileRepo.delete({ id }); - if (result.affected && result.affected <= 0) { + if (result.affected == undefined || result.affected <= 0) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } @@ -2523,7 +2527,7 @@ export class ProfileEmployeeController extends Controller { const history = new ProfileEmployeeInformationHistory(); Object.assign(history, { ...profileEmp, id: undefined }); - Object.assign(profileEmp, body) + Object.assign(profileEmp, body); history.profileEmployeeId = profileEmployeeId; history.lastUpdateFullName = request.user.name; history.lastUpdateUserId = request.user.sub; @@ -2540,7 +2544,7 @@ export class ProfileEmployeeController extends Controller { /** * API ประวัติการแก้ไขข้อมูลลูกจ้างชั่วคราว * - * @summary ประวัติการแก้ไขข้อมูลลูกจ้างชั่วคราว (ADMIN) + * @summary ประวัติการแก้ไขข้อมูลลูกจ้างชั่วคราว (ADMIN) * * @param {string} profileEmployeeId profileEmployeeId ทะเบียนประวัติลูกจ้างชั่วคราว */ @@ -2554,8 +2558,9 @@ export class ProfileEmployeeController extends Controller { }); if (!profileInformation) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - const mapData = profileInformation.flatMap((profile) => - profile.information_histories).map((history) => ({ + const mapData = profileInformation + .flatMap((profile) => profile.information_histories) + .map((history) => ({ id: history.id, positionEmployeeGroupId: history.positionEmployeeGroupId, positionEmployeeLineId: history.positionEmployeeLineId, @@ -2573,29 +2578,27 @@ export class ProfileEmployeeController extends Controller { lastUpdatedAt: history.lastUpdatedAt, lastUpdateUserId: history.lastUpdateUserId, lastUpdateFullName: history.lastUpdateFullName, - })); + })); return new HttpSuccess(mapData); } /** * API รายการข้อมูลการจ้าง * - * @summary รายการข้อมูลการจ้าง + * @summary รายการข้อมูลการจ้าง * * @param {string} profileEmployeeId profileEmployeeId ทะเบียนประวัติลูกจ้างชั่วคราว */ @Get("employment/{profileEmployeeId}") - async ProfileEmployeeEmployment( - @Path() profileEmployeeId: string, - ) { + async ProfileEmployeeEmployment(@Path() profileEmployeeId: string) { const employment = await this.employmentRepository.find({ where: { profileEmployeeId: profileEmployeeId }, - order: { createdAt : "ASC"} + order: { createdAt: "ASC" }, }); const mapData = employment.map((employment) => ({ - id: employment.id, - date: employment.date, - command: employment.command, + id: employment.id, + date: employment.date, + command: employment.command, })); return new HttpSuccess(mapData); } @@ -2603,14 +2606,12 @@ export class ProfileEmployeeController extends Controller { /** * API รายละเอียดข้อมูลการจ้าง * - * @summary รายละเอียดข้อมูลการจ้าง + * @summary รายละเอียดข้อมูลการจ้าง * * @param {string} id Id ข้อมูลการจ้าง */ @Get("employment/id/{id}") - async GetEmploymentById( - @Path() id: string, - ) { + async GetEmploymentById(@Path() id: string) { const employment = await this.employmentRepository.findOne({ where: { id: id }, }); @@ -2620,25 +2621,23 @@ export class ProfileEmployeeController extends Controller { /** * API ประวัติของข้อมูลการจ้าง * - * @summary ประวัติของข้อมูลการจ้าง + * @summary ประวัติของข้อมูลการจ้าง * * @param {string} id Id ข้อมูลการจ้าง */ @Get("employment/history/{id}") - async GetHistoryEmploymentById( - @Path() id: string, - ) { + async GetHistoryEmploymentById(@Path() id: string) { const employmentHistory = await this.employmentHistoryRepository.find({ where: { profileEmployeeEmploymentId: id }, - order: { lastUpdatedAt : "ASC"} + order: { lastUpdatedAt: "ASC" }, }); return new HttpSuccess(employmentHistory); } - + /** * API เพิ่มข้อมูลการจ้าง * - * @summary เพิ่มข้อมูลการจ้าง + * @summary เพิ่มข้อมูลการจ้าง * * @param {string} profileEmployeeId profileEmployeeId ทะเบียนประวัติลูกจ้างชั่วคราว */ @@ -2655,7 +2654,7 @@ export class ProfileEmployeeController extends Controller { const employment = new ProfileEmployeeEmployment(); // const history = new ProfileEmployeeEmploymentHistory(); - Object.assign(employment, body) + Object.assign(employment, body); employment.profileEmployeeId = profileEmployeeId; employment.createdUserId = request.user.sub; employment.createdFullName = request.user.name; @@ -2675,11 +2674,11 @@ export class ProfileEmployeeController extends Controller { } /** - * API ลบข้อมูลการจ้าง + * API ลบข้อมูลการจ้าง * * @summary ลบข้อมูลการจ้าง (ADMIN) * - * @param {string} id Id ข้อมูลการจ้าง + * @param {string} id Id ข้อมูลการจ้าง */ @Delete("employment/{id}") async DeleteEmployment(@Path() id: string) { @@ -2688,14 +2687,14 @@ export class ProfileEmployeeController extends Controller { }); const result = await this.employmentRepository.delete({ id }); - if (result.affected && result.affected <= 0) { + if (result.affected == undefined || result.affected <= 0) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } return new HttpSuccess(); } /** - * API แก้ไขข้อมูลการจ้าง + * API แก้ไขข้อมูลการจ้าง * * @summary แก้ไขข้อมูลการจ้าง (ADMIN) * @@ -2712,7 +2711,7 @@ export class ProfileEmployeeController extends Controller { const history = new ProfileEmployeeEmploymentHistory(); Object.assign(history, { ...employment, id: undefined }); - Object.assign(employment, body) + Object.assign(employment, body); employment.lastUpdateUserId = request.user.sub; employment.lastUpdateFullName = request.user.name; @@ -2722,10 +2721,9 @@ export class ProfileEmployeeController extends Controller { await Promise.all([ this.employmentRepository.save(employment), - this.employmentHistoryRepository.save(history) + this.employmentHistoryRepository.save(history), ]); return new HttpSuccess(); } - } diff --git a/src/controllers/ProfileFamilyHistoryController.ts b/src/controllers/ProfileFamilyHistoryController.ts index 39f45bcf..096a8676 100644 --- a/src/controllers/ProfileFamilyHistoryController.ts +++ b/src/controllers/ProfileFamilyHistoryController.ts @@ -148,7 +148,7 @@ export class ProfileFamilyHistoryController extends Controller { const family = await this.familyHistoryRepo.find({ order: { lastUpdatedAt: "DESC" }, where: { - profileId: profile.id + profileId: profile.id, }, }); @@ -413,7 +413,7 @@ export class ProfileFamilyHistoryController extends Controller { public async deleteFamilyHistory(@Path() profileId: string) { const result = await this.familyHistoryRepo.delete({ id: profileId }); - if (result.affected && result.affected <= 0) { + if (result.affected == undefined || result.affected <= 0) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } diff --git a/src/controllers/ProfileGovernmentController.ts b/src/controllers/ProfileGovernmentController.ts index 6b1d1508..fff540e3 100644 --- a/src/controllers/ProfileGovernmentController.ts +++ b/src/controllers/ProfileGovernmentController.ts @@ -318,7 +318,7 @@ export class ProfileGovernmentHistoryController extends Controller { // public async deleteGov(@Path() profileId: string) { // const result = await this.govRepo.delete({ profileId: profileId }); - // if (result.affected && result.affected <= 0) { + // if (result.affected == undefined || result.affected <= 0) { // throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); // } diff --git a/src/controllers/ProfileHonorController.ts b/src/controllers/ProfileHonorController.ts index d75e270c..84b9b226 100644 --- a/src/controllers/ProfileHonorController.ts +++ b/src/controllers/ProfileHonorController.ts @@ -195,7 +195,7 @@ export class ProfileHonorController extends Controller { const result = await this.honorRepo.delete({ id: honorId }); - if (result.affected && result.affected <= 0) { + if (result.affected == undefined || result.affected <= 0) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } diff --git a/src/controllers/ProfileInsigniaController.ts b/src/controllers/ProfileInsigniaController.ts index 184d3307..2f4f06db 100644 --- a/src/controllers/ProfileInsigniaController.ts +++ b/src/controllers/ProfileInsigniaController.ts @@ -237,7 +237,7 @@ export class ProfileInsigniaController extends Controller { const result = await this.insigniaRepo.delete({ id: insigniaId }); - if (result.affected && result.affected <= 0) { + if (result.affected == undefined || result.affected <= 0) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } diff --git a/src/controllers/ProfileLeaveController.ts b/src/controllers/ProfileLeaveController.ts index 41138a40..67cd4c0b 100644 --- a/src/controllers/ProfileLeaveController.ts +++ b/src/controllers/ProfileLeaveController.ts @@ -318,7 +318,7 @@ export class ProfileLeaveController extends Controller { const result = await this.leaveRepo.delete({ id: leaveId }); - if (result.affected && result.affected <= 0) { + if (result.affected == undefined || result.affected <= 0) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } diff --git a/src/controllers/ProfileNopaidController.ts b/src/controllers/ProfileNopaidController.ts index 06b163d8..c74b24d7 100644 --- a/src/controllers/ProfileNopaidController.ts +++ b/src/controllers/ProfileNopaidController.ts @@ -156,7 +156,7 @@ export class ProfileNopaidController extends Controller { const result = await this.nopaidRepository.delete({ id: nopaidId }); - if (result.affected && result.affected <= 0) { + if (result.affected == undefined || result.affected <= 0) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } diff --git a/src/controllers/ProfileOtherController.ts b/src/controllers/ProfileOtherController.ts index 5737a12d..11a986ec 100644 --- a/src/controllers/ProfileOtherController.ts +++ b/src/controllers/ProfileOtherController.ts @@ -153,7 +153,7 @@ export class ProfileOtherController extends Controller { const result = await this.otherRepository.delete({ id: otherId }); - if (result.affected && result.affected <= 0) { + if (result.affected == undefined || result.affected <= 0) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } diff --git a/src/controllers/ProfileSalaryController.ts b/src/controllers/ProfileSalaryController.ts index cf565bcc..eb9c66a7 100644 --- a/src/controllers/ProfileSalaryController.ts +++ b/src/controllers/ProfileSalaryController.ts @@ -203,7 +203,7 @@ export class ProfileSalaryController extends Controller { const result = await this.salaryRepo.delete({ id: salaryId }); - if (result.affected && result.affected <= 0) { + if (result.affected == undefined || result.affected <= 0) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } diff --git a/src/controllers/ProfileTrainingController.ts b/src/controllers/ProfileTrainingController.ts index 4c9b20a7..20de8cf8 100644 --- a/src/controllers/ProfileTrainingController.ts +++ b/src/controllers/ProfileTrainingController.ts @@ -196,7 +196,7 @@ export class ProfileTrainingController extends Controller { const result = await this.trainingRepo.delete({ id: trainingId }); - if (result.affected && result.affected <= 0) { + if (result.affected == undefined || result.affected <= 0) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); }