diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 9867c9b0..801e7258 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -570,6 +570,31 @@ export class ProfileController extends Controller { return new HttpSuccess(profile); } + /** + * API ประวัติการแก้ไขรายการทะเบียนประวัติ + * + * @summary ประวัติการแก้ไขรายการทะเบียนประวัติ + * + * @param {string} id Id โปรไฟล์ + */ + @Get("history/user") + async getHistoryProfileByUser(@Request() request: RequestWithUser) { + const historyProfile = await this.profileHistoryRepo.find({ + relations: { + posLevel: true, + posType: true, + }, + where: { keycloak: request.user.sub }, + order: { + createdAt:"ASC", + } + }); + + if (!historyProfile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + + return new HttpSuccess(historyProfile); + } + /** * API รายละเอียดรายการทะเบียนประวัติ * diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 89dcb41f..d623f503 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -392,6 +392,31 @@ export class ProfileEmployeeController extends Controller { return new HttpSuccess(profile); } + /** + * API ประวัติการแก้ไขรายการทะเบียนประวัติ + * + * @summary ประวัติการแก้ไขรายการทะเบียนประวัติ + * + * @param {string} id Id โปรไฟล์ + */ + @Get("history/user") + async getHistoryProfileByUser(@Request() request: RequestWithUser) { + const historyProfile = await this.profileHistoryRepo.find({ + relations: { + posLevel: true, + posType: true, + }, + where: { keycloak: request.user.sub }, + order: { + createdAt: "ASC", + }, + }); + + if (!historyProfile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + + return new HttpSuccess(historyProfile); + } + /** * API รายละเอียดรายการทะเบียนประวัติ * @@ -998,22 +1023,22 @@ export class ProfileEmployeeController extends Controller { } } - const rootHolder = item.current_holders?.find( - (x) => x.orgRevisionId == findRevision.id, - )?.orgRoot; - const child1Holder = item.current_holders?.find( - (x) => x.orgRevisionId == findRevision.id, - )?.orgChild1; - const child2Holder = item.current_holders?.find( - (x) => x.orgRevisionId == findRevision.id, - )?.orgChild2; - const child3Holder = item.current_holders?.find( - (x) => x.orgRevisionId == findRevision.id, - )?.orgChild3; - const child4Holder = item.current_holders?.find( - (x) => x.orgRevisionId == findRevision.id, + const rootHolder = item.current_holders?.find( + (x) => x.orgRevisionId == findRevision.id, + )?.orgRoot; + const child1Holder = item.current_holders?.find( + (x) => x.orgRevisionId == findRevision.id, + )?.orgChild1; + const child2Holder = item.current_holders?.find( + (x) => x.orgRevisionId == findRevision.id, + )?.orgChild2; + const child3Holder = item.current_holders?.find( + (x) => x.orgRevisionId == findRevision.id, + )?.orgChild3; + const child4Holder = item.current_holders?.find( + (x) => x.orgRevisionId == findRevision.id, )?.orgChild4; - + return { id: item.id, prefix: item.prefix,