diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index 7cd02310..43c823c4 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -4504,4 +4504,58 @@ export class OrganizationDotnetController extends Controller { }; return new HttpSuccess(mapProfile); } + + /** + * API Get Profile ใช้อัพเดทสถานะ Mark ในระบบเครื่องราช + * + * @summary API Get Profile ใช้อัพเดทสถานะ Mark ในระบบเครื่องราช + * + * @param {string} type ประเภท (ข้าราชการ หรือ ลูกจ้าง) + */ + @Post("find/insignia-requests-profile/{type}") + async GetInsigniaRequestsProfileAsync( + @Request() req: RequestWithUser, + @Path() type: string, + @Body() + body: { + profileIds: string[]; + }, + ) { + let profile; + if (type.trim().toLocaleUpperCase() == "OFFICER") { + profile = await this.profileRepo.find({ + relations: [ + "profileSalary", + "profileInsignias", + "profileDisciplines", + "profileAssessments" + ], + where: { id: In(body.profileIds) } + }); + } + else { + profile = await this.profileEmpRepo.find({ + relations: [ + "profileSalary", + "profileInsignias", + "profileDisciplines", + "profileAssessments" + ], + where: { id: In(body.profileIds) } + }); + } + + if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + + const mapProfile = profile.map((x) => { + return { + id: x.id, + markDiscipline: x.profileDisciplines.length > 0 ? true : false, + markLeave: false, + markRate: x.profileAssessments.length > 0 ? true : false, + markInsignia: x.profileInsignias.length > 0 ? true : false, + }; + }); + return new HttpSuccess(mapProfile); + } }