From 24c5cbef55143814d21020dc8fb770684cf2f554 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 23 May 2024 17:20:15 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=84=E0=B9=89?= =?UTF-8?q?=E0=B8=99=E0=B8=AB=E0=B8=B2=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7?= =?UTF-8?q?=E0=B8=B1=E0=B8=95=E0=B8=B4=20by=20token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileAddressController.ts | 2 +- src/controllers/ProfileCertificateController.ts | 2 +- src/controllers/ProfileFamilyHistoryController.ts | 4 ++-- src/controllers/ProfileFamilyMotherController.ts | 2 +- src/controllers/ProfileInsigniaController.ts | 2 +- src/controllers/ProfileLeaveController.ts | 2 +- src/controllers/ProfileNopaidController.ts | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/controllers/ProfileAddressController.ts b/src/controllers/ProfileAddressController.ts index e2edab5f..497d45b7 100644 --- a/src/controllers/ProfileAddressController.ts +++ b/src/controllers/ProfileAddressController.ts @@ -41,7 +41,7 @@ export class ProfileAddressController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const getProfileAddress = await this.profileRepo.findOne({ - where: { id: request.user.sub }, + where: { id: profile.id }, select: [ "id", "registrationAddress", diff --git a/src/controllers/ProfileCertificateController.ts b/src/controllers/ProfileCertificateController.ts index 56f08974..10185798 100644 --- a/src/controllers/ProfileCertificateController.ts +++ b/src/controllers/ProfileCertificateController.ts @@ -33,7 +33,7 @@ export class ProfileCertificateController extends Controller { private certificateRepo = AppDataSource.getRepository(ProfileCertificate); private certificateHistoryRepo = AppDataSource.getRepository(ProfileCertificateHistory); - @Get("{profileId}") + @Get("user") public async getCertificateUser(@Request() request: { user: Record }) { const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub }); if (!profile) { diff --git a/src/controllers/ProfileFamilyHistoryController.ts b/src/controllers/ProfileFamilyHistoryController.ts index 1ea363ea..7928ef92 100644 --- a/src/controllers/ProfileFamilyHistoryController.ts +++ b/src/controllers/ProfileFamilyHistoryController.ts @@ -45,11 +45,11 @@ export class ProfileFamilyHistoryController extends Controller { const family = await this.familyHistoryRepo.find({ take: 1, order: { lastUpdatedAt: "DESC" }, - where: { id: profile.id }, + where: { profileId: profile.id }, }); const children = await this.childrenRepo.find({ order: { createdAt: "ASC" }, - where: { id: profile.id }, + where: { profileId: profile.id }, }); return new HttpSuccess( family.length > 0 diff --git a/src/controllers/ProfileFamilyMotherController.ts b/src/controllers/ProfileFamilyMotherController.ts index 879b7795..cad827d2 100644 --- a/src/controllers/ProfileFamilyMotherController.ts +++ b/src/controllers/ProfileFamilyMotherController.ts @@ -50,7 +50,7 @@ export class ProfileFamilyMotherController extends Controller { "motherLive", "profileId", ], - where: { id: profile.id }, + where: { profileId: profile.id }, order: { lastUpdatedAt: "DESC" }, }); diff --git a/src/controllers/ProfileInsigniaController.ts b/src/controllers/ProfileInsigniaController.ts index 1f1d9ec3..184d3307 100644 --- a/src/controllers/ProfileInsigniaController.ts +++ b/src/controllers/ProfileInsigniaController.ts @@ -47,7 +47,7 @@ export class ProfileInsigniaController extends Controller { insigniaType: true, }, }, - where: { id: profile.id }, + where: { profileId: profile.id }, }); return new HttpSuccess(record); } diff --git a/src/controllers/ProfileLeaveController.ts b/src/controllers/ProfileLeaveController.ts index 07289054..60e866b2 100644 --- a/src/controllers/ProfileLeaveController.ts +++ b/src/controllers/ProfileLeaveController.ts @@ -44,7 +44,7 @@ export class ProfileLeaveController extends Controller { } const record = await this.leaveRepo.find({ relations: { leaveType: true }, - where: { id: profile.id }, + where: { profileId: profile.id }, }); return new HttpSuccess(record); } diff --git a/src/controllers/ProfileNopaidController.ts b/src/controllers/ProfileNopaidController.ts index d79a0f0b..06b163d8 100644 --- a/src/controllers/ProfileNopaidController.ts +++ b/src/controllers/ProfileNopaidController.ts @@ -36,7 +36,7 @@ export class ProfileNopaidController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const lists = await this.nopaidRepository.find({ - where: { id: profile.id }, + where: { profileId: profile.id }, }); return new HttpSuccess(lists); }