From a66f582c25636ca47e704f579c64edf82dcf243a Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 28 May 2024 10:20:50 +0700 Subject: [PATCH] add api history/user done --- src/controllers/ProfileHonorController.ts | 21 +++++++++++++++++++ .../ProfileHonorEmployeeController.ts | 21 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/src/controllers/ProfileHonorController.ts b/src/controllers/ProfileHonorController.ts index a66fa2d6..d75e270c 100644 --- a/src/controllers/ProfileHonorController.ts +++ b/src/controllers/ProfileHonorController.ts @@ -69,6 +69,27 @@ export class ProfileHonorController extends Controller { return new HttpSuccess(record); } + /** + * + * @summary ประวัติแก้ไขเกียรติประวัติ by keycloak + * + */ + @Get("history/user") + public async honorHistoryUser(@Request() request: RequestWithUser) { + const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub }); + if (!profile) { + throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); + } + const record = await this.honorHistoryRepo.find({ + where: { + histories: { + profileId: profile.id, + }, + }, + }); + return new HttpSuccess(record); + } + @Get("history/{honorId}") @Example({ status: 200, diff --git a/src/controllers/ProfileHonorEmployeeController.ts b/src/controllers/ProfileHonorEmployeeController.ts index afaf9a00..a6b232ad 100644 --- a/src/controllers/ProfileHonorEmployeeController.ts +++ b/src/controllers/ProfileHonorEmployeeController.ts @@ -69,6 +69,27 @@ export class ProfileHonorEmployeeController extends Controller { return new HttpSuccess(record); } + /** + * + * @summary ประวัติแก้ไขเกียรติประวัติ by keycloak + * + */ + @Get("history/user") + public async honorHistoryUser(@Request() request: RequestWithUser) { + const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub }); + if (!profile) { + throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); + } + const record = await this.honorHistoryRepo.find({ + where: { + histories: { + profileEmployeeId: profile.id, + }, + }, + }); + return new HttpSuccess(record); + } + @Get("history/{honorId}") @Example({ status: 200,