From 2df1e19dc3f87f0fa33e5806669c77396cb4f6ee Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 27 Nov 2024 10:20:40 +0700 Subject: [PATCH] =?UTF-8?q?sort=20=E0=B8=82=E0=B9=89=E0=B8=AD=E0=B8=A1?= =?UTF-8?q?=E0=B8=B9=E0=B8=A5=E0=B8=AB=E0=B8=A5=E0=B8=B1=E0=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/BloodGroupController.ts | 6 +- src/controllers/EducationLevelController.ts | 9 +- src/controllers/EmployeePosTypeController.ts | 3 + src/controllers/EmployeePositionController.ts | 55 ++++++--- src/controllers/GenderController.ts | 5 +- src/controllers/PosExecutiveController.ts | 3 - src/controllers/PosTypeController.ts | 7 +- src/controllers/PositionController.ts | 116 +++++++++++++++++- src/controllers/PrefixController.ts | 5 +- src/controllers/ProvinceController.ts | 2 +- src/controllers/RankController.ts | 6 +- src/controllers/RelationshipController.ts | 5 +- src/controllers/ReligionController.ts | 6 +- 13 files changed, 171 insertions(+), 57 deletions(-) diff --git a/src/controllers/BloodGroupController.ts b/src/controllers/BloodGroupController.ts index 4d0d57c7..f803a03e 100644 --- a/src/controllers/BloodGroupController.ts +++ b/src/controllers/BloodGroupController.ts @@ -147,12 +147,8 @@ export class BloodGroupController extends Controller { async listBloodGroup() { const bloodGroup = await this.bloodGroupRepository.find({ select: ["id", "name", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"], - order: { name: "ASC" }, + order: { createdAt: "DESC" }, }); - - // if (!bloodGroup) { - // return new HttpSuccess([]); - // } return new HttpSuccess(bloodGroup); } } diff --git a/src/controllers/EducationLevelController.ts b/src/controllers/EducationLevelController.ts index 0e669a90..eecdbda0 100644 --- a/src/controllers/EducationLevelController.ts +++ b/src/controllers/EducationLevelController.ts @@ -162,12 +162,11 @@ export class EducationLevelController extends Controller { "createdFullName", "lastUpdateFullName", ], - order: { rank: "ASC" }, + order: { + rank: "ASC", + createdAt: "DESC" + }, }); - - // if (!educationLevel) { - // return new HttpSuccess([]); - // } return new HttpSuccess(educationLevel); } } diff --git a/src/controllers/EmployeePosTypeController.ts b/src/controllers/EmployeePosTypeController.ts index 907a5d1a..aedabafe 100644 --- a/src/controllers/EmployeePosTypeController.ts +++ b/src/controllers/EmployeePosTypeController.ts @@ -197,8 +197,10 @@ export class EmployeePosTypeController extends Controller { select: ["id", "posTypeName", "posTypeRank", "posTypeShortName", "createdAt", "lastUpdatedAt", "lastUpdateFullName"], where: { id: id }, order: { + posTypeRank: "ASC", createdAt: "DESC", posLevels: { + posLevelRank: "ASC", createdAt: "DESC" } } @@ -246,6 +248,7 @@ export class EmployeePosTypeController extends Controller { posTypeRank: "ASC", createdAt: "DESC", posLevels: { + posLevelRank: "ASC", createdAt: "DESC", } }, diff --git a/src/controllers/EmployeePositionController.ts b/src/controllers/EmployeePositionController.ts index eba57fe7..aca7dd6d 100644 --- a/src/controllers/EmployeePositionController.ts +++ b/src/controllers/EmployeePositionController.ts @@ -288,12 +288,17 @@ export class EmployeePositionController extends Controller { findData = await this.employeePosDictRepository.find({ where: { posDictName: Like(`%${keyword}%`) }, relations: ["posType", "posLevel"], - order: { + order: { + posDictName: "ASC", + createdAt: "DESC", + posType:{ + posTypeRank: "ASC", + createdAt: "DESC" + }, posLevel: { posLevelName: "ASC", createdAt: "DESC" - }, - createdAt: "DESC" + } }, }); break; @@ -306,12 +311,17 @@ export class EmployeePositionController extends Controller { findData = await this.employeePosDictRepository.find({ where: { posTypeId: In(findEmpTypes.map((x) => x.id)) }, relations: ["posType", "posLevel"], - order: { + order: { + posDictName: "ASC", + createdAt: "DESC", + posType:{ + posTypeRank: "ASC", + createdAt: "DESC" + }, posLevel: { posLevelName: "ASC", createdAt: "DESC" - }, - createdAt: "DESC" + } }, }); break; @@ -324,24 +334,34 @@ export class EmployeePositionController extends Controller { findData = await this.employeePosDictRepository.find({ where: { posLevelId: In(findEmpLevels.map((x) => x.id)) }, relations: ["posType", "posLevel"], - order: { + order: { + posDictName: "ASC", + createdAt: "DESC", + posType:{ + posTypeRank: "ASC", + createdAt: "DESC" + }, posLevel: { posLevelName: "ASC", createdAt: "DESC" - }, - createdAt: "DESC" + } }, }); } else { //กรณีเลือกค้นหาจาก"ระดับชั้นงาน" แต่กรอกไม่ใช่ number ให้ปล่อยมาหมดเลย findData = await this.employeePosDictRepository.find({ relations: ["posType", "posLevel"], - order: { + order: { + posDictName: "ASC", + createdAt: "DESC", + posType:{ + posTypeRank: "ASC", + createdAt: "DESC" + }, posLevel: { posLevelName: "ASC", createdAt: "DESC" - }, - createdAt: "DESC" + } }, }); } @@ -350,12 +370,17 @@ export class EmployeePositionController extends Controller { default: findData = await this.employeePosDictRepository.find({ relations: ["posType", "posLevel"], - order: { + order: { + posDictName: "ASC", + createdAt: "DESC", + posType:{ + posTypeRank: "ASC", + createdAt: "DESC" + }, posLevel: { posLevelName: "ASC", createdAt: "DESC" - }, - createdAt: "DESC" + } }, }); break; diff --git a/src/controllers/GenderController.ts b/src/controllers/GenderController.ts index 499baff8..8d3a8eb6 100644 --- a/src/controllers/GenderController.ts +++ b/src/controllers/GenderController.ts @@ -41,11 +41,8 @@ export class GenderController extends Controller { async GetResult() { const _gender = await this.genderRepository.find({ select: ["id", "name", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"], - order: { name: "ASC" }, + order: { createdAt: "DESC" }, }); - // if (!_gender) { - // return new HttpSuccess([]); - // } return new HttpSuccess(_gender); } diff --git a/src/controllers/PosExecutiveController.ts b/src/controllers/PosExecutiveController.ts index 946535cf..f7632364 100644 --- a/src/controllers/PosExecutiveController.ts +++ b/src/controllers/PosExecutiveController.ts @@ -210,9 +210,6 @@ export class PosExecutiveController extends Controller { createdAt: "DESC" }, }); - // if (!posExecutive) { - // return new HttpSuccess([]); - // } return new HttpSuccess(posExecutive); } } diff --git a/src/controllers/PosTypeController.ts b/src/controllers/PosTypeController.ts index 72ae9e99..26a88365 100644 --- a/src/controllers/PosTypeController.ts +++ b/src/controllers/PosTypeController.ts @@ -185,8 +185,10 @@ export class PosTypeController extends Controller { relations: ["posLevels"], where: { id: id }, order: { + posTypeRank: "ASC", createdAt: "DESC", posLevels: { + posLevelRank: "ASC", createdAt: "DESC", } } @@ -248,13 +250,12 @@ export class PosTypeController extends Controller { posTypeRank: "ASC", createdAt: "DESC", posLevels: { + posLevelRank: "ASC", createdAt: "DESC" } }, }); - // if (!posType) { - // return new HttpSuccess([]); - // } + const mapPosType = posType.map((item) => ({ id: item.id, posTypeName: item.posTypeName, diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index eca0908f..b626ba09 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -570,6 +570,17 @@ export class PositionController extends Controller { order: { posDictName: "ASC", createdAt: "DESC", + posType:{ + posTypeRank: "ASC", + createdAt: "DESC" + }, + posLevel: { + posLevelRank: "ASC", + createdAt: "DESC" + }, + posExecutive: { + posExecutivePriority: "ASC" + } }, }); break; @@ -581,6 +592,17 @@ export class PositionController extends Controller { order: { posDictField: "ASC", createdAt: "DESC", + posType:{ + posTypeRank: "ASC", + createdAt: "DESC" + }, + posLevel: { + posLevelRank: "ASC", + createdAt: "DESC" + }, + posExecutive: { + posExecutivePriority: "ASC" + } }, }); break; @@ -588,7 +610,11 @@ export class PositionController extends Controller { case "positionType": const findTypes: PosType[] = await this.posTypeRepository.find({ where: { posTypeName: Like(`%${keyword}%`) }, - order: { posTypeName: "ASC" }, + order: { + // posTypeName: "ASC" + posTypeRank: "ASC", + createdAt: "DESC" + }, select: ["id"], }); findPosDict = await this.posDictRepository.find({ @@ -597,6 +623,17 @@ export class PositionController extends Controller { order: { posDictName: "ASC", createdAt: "DESC", + posType:{ + posTypeRank: "ASC", + createdAt: "DESC" + }, + posLevel: { + posLevelRank: "ASC", + createdAt: "DESC" + }, + posExecutive: { + posExecutivePriority: "ASC" + } }, }); break; @@ -604,7 +641,11 @@ export class PositionController extends Controller { case "positionLevel": const findLevel: PosLevel[] = await this.posLevelRepository.find({ where: { posLevelName: Like(`%${keyword}%`) }, - order: { posLevelName: "ASC" }, + order: { + // posLevelName: "ASC" + posLevelRank: "ASC", + createdAt: "DESC" + }, select: ["id"], }); findPosDict = await this.posDictRepository.find({ @@ -613,6 +654,17 @@ export class PositionController extends Controller { order: { posDictName: "ASC", createdAt: "DESC", + posType:{ + posTypeRank: "ASC", + createdAt: "DESC" + }, + posLevel: { + posLevelRank: "ASC", + createdAt: "DESC" + }, + posExecutive: { + posExecutivePriority: "ASC" + } }, }); break; @@ -620,7 +672,10 @@ export class PositionController extends Controller { case "positionExecutive": const findExecutive: PosExecutive[] = await this.posExecutiveRepository.find({ where: { posExecutiveName: Like(`%${keyword}%`) }, - order: { posExecutiveName: "ASC" }, + order: { + // posExecutiveName: "ASC" + posExecutivePriority: "ASC" + }, select: ["id"], }); findPosDict = await this.posDictRepository.find({ @@ -629,6 +684,17 @@ export class PositionController extends Controller { order: { posDictName: "ASC", createdAt: "DESC", + posType:{ + posTypeRank: "ASC", + createdAt: "DESC" + }, + posLevel: { + posLevelRank: "ASC", + createdAt: "DESC" + }, + posExecutive: { + posExecutivePriority: "ASC" + } }, }); break; @@ -640,6 +706,17 @@ export class PositionController extends Controller { order: { posDictName: "ASC", createdAt: "DESC", + posType:{ + posTypeRank: "ASC", + createdAt: "DESC" + }, + posLevel: { + posLevelRank: "ASC", + createdAt: "DESC" + }, + posExecutive: { + posExecutivePriority: "ASC" + } }, }); break; @@ -651,6 +728,17 @@ export class PositionController extends Controller { order: { posDictName: "ASC", createdAt: "DESC", + posType:{ + posTypeRank: "ASC", + createdAt: "DESC" + }, + posLevel: { + posLevelRank: "ASC", + createdAt: "DESC" + }, + posExecutive: { + posExecutivePriority: "ASC" + } }, }); break; @@ -688,6 +776,17 @@ export class PositionController extends Controller { order: { posDictName: "ASC", createdAt: "DESC", + posType:{ + posTypeRank: "ASC", + createdAt: "DESC" + }, + posLevel: { + posLevelRank: "ASC", + createdAt: "DESC" + }, + posExecutive: { + posExecutivePriority: "ASC" + } }, }); break; @@ -698,6 +797,17 @@ export class PositionController extends Controller { order: { posDictName: "ASC", createdAt: "DESC", + posType:{ + posTypeRank: "ASC", + createdAt: "DESC" + }, + posLevel: { + posLevelRank: "ASC", + createdAt: "DESC" + }, + posExecutive: { + posExecutivePriority: "ASC" + } }, }); break; diff --git a/src/controllers/PrefixController.ts b/src/controllers/PrefixController.ts index ff0cb461..d8bdea7a 100644 --- a/src/controllers/PrefixController.ts +++ b/src/controllers/PrefixController.ts @@ -41,11 +41,8 @@ export class PrefixController extends Controller { async Get() { const _prefix = await this.prefixRepository.find({ select: ["id", "name", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"], - order: { name: "ASC" }, + order: { createdAt: "DESC" }, }); - // if (!_prefix) { - // return new HttpSuccess([]); - // } return new HttpSuccess(_prefix); } diff --git a/src/controllers/ProvinceController.ts b/src/controllers/ProvinceController.ts index 56433c93..6d4574f6 100644 --- a/src/controllers/ProvinceController.ts +++ b/src/controllers/ProvinceController.ts @@ -41,7 +41,7 @@ export class ProvinceController extends Controller { async GetResult() { const _province = await this.provinceRepository.find({ select: ["id", "name", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"], - order: { name: "ASC" }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(_province); } diff --git a/src/controllers/RankController.ts b/src/controllers/RankController.ts index a23f9692..fa9475ce 100644 --- a/src/controllers/RankController.ts +++ b/src/controllers/RankController.ts @@ -147,12 +147,8 @@ export class RankController extends Controller { async listRank() { const rank = await this.rankRepository.find({ select: ["id", "name", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"], - order: { name: "ASC" }, + order: { createdAt: "DESC" }, }); - - // if (!rank) { - // return new HttpSuccess([]); - // } return new HttpSuccess(rank); } } diff --git a/src/controllers/RelationshipController.ts b/src/controllers/RelationshipController.ts index 0d446a98..0643b874 100644 --- a/src/controllers/RelationshipController.ts +++ b/src/controllers/RelationshipController.ts @@ -147,11 +147,8 @@ export class RelationshipController extends Controller { async listRelationship() { const relationship = await this.relationshipRepository.find({ select: ["id", "name", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"], - order: { name: "ASC" }, + order: { createdAt: "DESC" }, }); - // if (!relationship) { - // return new HttpSuccess([]); - // } return new HttpSuccess(relationship); } } diff --git a/src/controllers/ReligionController.ts b/src/controllers/ReligionController.ts index baf1a821..0562858e 100644 --- a/src/controllers/ReligionController.ts +++ b/src/controllers/ReligionController.ts @@ -146,12 +146,8 @@ export class ReligionController extends Controller { async listReligion() { const religion = await this.religionRepository.find({ select: ["id", "name", "createdAt", "lastUpdatedAt", "createdFullName", "lastUpdateFullName"], - order: { name: "ASC" }, + order: { createdAt: "DESC" }, }); - - // if (!religion) { - // return new HttpSuccess([]); - // } return new HttpSuccess(religion); } }