From b456fe46ff51105ea4845bfa0ca2580721798b6c Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 19 Nov 2024 14:34:33 +0700 Subject: [PATCH] sort data #798 --- src/controllers/PositionController.ts | 10 +++++++++- src/controllers/ProfileController.ts | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 0eb6f2fa..9cc106e4 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -1121,7 +1121,15 @@ export class PositionController extends Controller { const positions = await this.positionRepository.find({ where: { posMasterId: posMaster.id }, relations: ["posType", "posLevel", "posExecutive"], - order: { lastUpdatedAt: "ASC" }, + // order: { lastUpdatedAt: "ASC" }, + order: { + posType: { + posTypeRank: "ASC" + }, + posLevel: { + posLevelRank: "ASC" + } + }, }); const formattedData = { id: posMaster.id, diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 5d5d9faf..77940e9e 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -4310,6 +4310,8 @@ export class ProfileController extends Controller { ) .skip((requestBody.page - 1) * requestBody.pageSize) .take(requestBody.pageSize) + .orderBy("posType.posTypeRank", "ASC") + .addOrderBy("posLevel.posLevelRank", "ASC") .getManyAndCount(); const data = profiles.map((_data) => ({