From e7dd0e64cb931151ed937eaf22f1551e31c0a140 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 12 Jun 2024 14:50:20 +0700 Subject: [PATCH] limit commander --- src/controllers/ProfileController.ts | 32 ++++++++++++++++++---------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index aa1f0d0a..f4e53083 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -563,17 +563,27 @@ export class ProfileController extends Controller { where: { keycloak: request.user.sub }, }); - if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - - const _caregiver = await this.profileRepo.find({ - relations: { posLevel: true, posType: true }, - }); - const _commander = await this.profileRepo.find({ - relations: { posLevel: true, posType: true }, - }); - const _chairman = await this.profileRepo.find({ - relations: { posLevel: true, posType: true }, - }); + const _caregiver = await this.profileRepo + .createQueryBuilder("profile") + .leftJoinAndSelect("profile.posLevel", "posLevel") + .leftJoinAndSelect("profile.posType", "posType") + .skip((1 - 1) * 20) + .take(20) + .getMany(); + const _commander = await this.profileRepo + .createQueryBuilder("profile") + .leftJoinAndSelect("profile.posLevel", "posLevel") + .leftJoinAndSelect("profile.posType", "posType") + .skip((1 - 1) * 20) + .take(20) + .getMany(); + const _chairman = await this.profileRepo + .createQueryBuilder("profile") + .leftJoinAndSelect("profile.posLevel", "posLevel") + .leftJoinAndSelect("profile.posType", "posType") + .skip((1 - 1) * 20) + .take(20) + .getMany(); const caregiver = _caregiver.map((_data) => ({ id: _data.id,