From ac1599485abc2e0b90b03254126d632c3e97fb26 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 14 Mar 2024 11:21:55 +0700 Subject: [PATCH] Fix --- src/controllers/EmployeePosLevelController.ts | 2 ++ src/controllers/EmployeePosTypeController.ts | 6 +++-- src/controllers/InsigniaController.ts | 7 +++--- src/controllers/InsigniaTypeController.ts | 24 +++++++++++++++---- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/controllers/EmployeePosLevelController.ts b/src/controllers/EmployeePosLevelController.ts index 782cf561..b43d6d56 100644 --- a/src/controllers/EmployeePosLevelController.ts +++ b/src/controllers/EmployeePosLevelController.ts @@ -176,6 +176,7 @@ export class EmployeePosLevelController extends Controller { const mapEmpPosLevel = { id: getEmpPosLevel.id, posLevelName: getEmpPosLevel.posLevelName, + posTypeId: getEmpPosLevel.posType == null ? null : getEmpPosLevel.posType.id, posTypeName: getEmpPosLevel.posType == null ? null : getEmpPosLevel.posType.posTypeName, //กลุ่มงาน commander: null, //ผู้มีอำนาจสั่งบรรจุ }; @@ -197,6 +198,7 @@ export class EmployeePosLevelController extends Controller { const mapEmpPosLevel = empPosLevel.map((item) => ({ id: item.id, posLevelName: item.posLevelName, + posTypeId: item.posType == null ? null : item.posType.id, posTypeName: item.posType == null ? null : item.posType.posTypeName, //กลุ่มงาน commander: null, //ผู้มีอำนาจสั่งบรรจุ })); diff --git a/src/controllers/EmployeePosTypeController.ts b/src/controllers/EmployeePosTypeController.ts index d20e2206..08b9859a 100644 --- a/src/controllers/EmployeePosTypeController.ts +++ b/src/controllers/EmployeePosTypeController.ts @@ -154,7 +154,7 @@ export class EmployeePosTypeController extends Controller { async GetEmpTypeById(@Path() id: string) { const getEmpPosType = await this.employeePosTypeRepository.findOne({ relations: ["posLevels"], - select: ["id", "posTypeName", "posTypeRank"], + select: ["id", "posTypeName", "posTypeRank", "posTypeShortName"], where: { id: id }, }); if (!getEmpPosType) { @@ -165,6 +165,7 @@ export class EmployeePosTypeController extends Controller { id: getEmpPosType.id, posTypeName: getEmpPosType.posTypeName, posTypeRank: getEmpPosType.posTypeRank, + posTypeShortName: getEmpPosType.posTypeShortName, posLevels: getEmpPosType.posLevels.map((empPosLevel) => ({ id: empPosLevel.id, posLevelName: empPosLevel.posLevelName, @@ -185,13 +186,14 @@ export class EmployeePosTypeController extends Controller { async GetEmpPosType() { const empPosType = await this.employeePosTypeRepository.find({ relations: ["posLevels"], - select: ["id", "posTypeName", "posTypeRank"], + select: ["id", "posTypeName", "posTypeRank", "posTypeShortName"], }); const mapEmpPosType = empPosType.map((item) => ({ id: item.id, posTypeName: item.posTypeName, posTypeRank: item.posTypeRank, + posTypeShortName: item.posTypeShortName, posLevels: item.posLevels.map((empPosLevel) => ({ id: empPosLevel.id, posLevelName: empPosLevel.posLevelName, diff --git a/src/controllers/InsigniaController.ts b/src/controllers/InsigniaController.ts index c1355f2d..a0069f44 100644 --- a/src/controllers/InsigniaController.ts +++ b/src/controllers/InsigniaController.ts @@ -24,7 +24,7 @@ import { Equal, ILike, In, IsNull, Like, Not, Brackets, Between } from "typeorm" import { InsigniaType, CreateInsigniaType, UpdateInsigniaType } from "../entities/InsigniaType"; import { Insignia, CreateInsignias, UpdateInsignias } from "../entities/Insignia"; -@Route("api/v1/org/insignia/Insignias") +@Route("api/v1/org/insignia/insignia") @Tags("Insignia") @Security("bearerAuth") @Response( @@ -180,10 +180,9 @@ export class InsigniaController extends Controller { const insigniaAll = await this.insigniaRepository.find({ relations: ["insigniaType"], select: ["id", "name", "shortName", "createdAt", "lastUpdatedAt", "lastUpdateFullName", "isActive", "note"], + order: { "level": "ASC" } }); - if (!insigniaAll) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลเครื่องราชอิสริยาภรณ์นี้"); - } + const mapInsigniaAll = insigniaAll.map((item) => ({ id: item.id, name: item.name, diff --git a/src/controllers/InsigniaTypeController.ts b/src/controllers/InsigniaTypeController.ts index cfd8ec86..164aaf93 100644 --- a/src/controllers/InsigniaTypeController.ts +++ b/src/controllers/InsigniaTypeController.ts @@ -132,6 +132,22 @@ export class InsigniaTypeController extends Controller { return new HttpSuccess(); } + /** + * API รายการลำดับชั้นเครื่องราชอิสริยาภรณ์ Active + * + * @summary ORG_ - รายการลำดับชั้นเครื่องราชอิสริยาภรณ์ Active (ADMIN) # + * + */ + @Get("active") + async GetInsigniaType_Active() { + const insigniaType_Active = await this.insigniaTypeRepository.find({ + select: ["id", "name", "createdAt", "lastUpdatedAt", "lastUpdateFullName", "isActive"], + where: { isActive: true }, + order: { "name": "ASC" } + }); + return new HttpSuccess(insigniaType_Active); + } + /** * API รายละเอียดข้อมูลลำดับชั้นเครื่องราชอิสริยาภรณ์ * @@ -142,6 +158,7 @@ export class InsigniaTypeController extends Controller { @Get("{id}") async GetInsigniaTypeById(@Path() id: string) { const insigniaType = await this.insigniaTypeRepository.findOne({ + relations: ["insignias"], select: ["id", "name", "createdAt", "lastUpdatedAt", "lastUpdateFullName", "isActive"], where: { id: id }, }); @@ -159,13 +176,10 @@ export class InsigniaTypeController extends Controller { */ @Get("") async GetInsigniaType() { - const insigniaTypeAll = await this.insigniaTypeRepository.find({ - select: ["id", "name", "createdAt", "lastUpdatedAt", "lastUpdateFullName", "isActive"] + select: ["id", "name", "createdAt", "lastUpdatedAt", "lastUpdateFullName", "isActive"], + order: { "name": "ASC" } }); - if (!insigniaTypeAll) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลลำดับชั้นเครื่องราชอิสริยาภรณ์ นี้"); - } return new HttpSuccess(insigniaTypeAll); } }