From 70ef98707a94a06d10e4ea1717b0ee8c7748f1f8 Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 1 Nov 2024 14:42:55 +0700 Subject: [PATCH 1/2] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=84?= =?UTF-8?q?=E0=B9=89=E0=B8=99=E0=B8=AB=E0=B8=B2=E0=B8=95=E0=B8=B3=E0=B9=81?= =?UTF-8?q?=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=87=E0=B8=9A=E0=B8=A3=E0=B8=A3?= =?UTF-8?q?=E0=B8=88=E0=B8=B8=20#747?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/PositionController.ts | 67 ++++++++++++++++++++------- 1 file changed, 51 insertions(+), 16 deletions(-) diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 589a4884..dc97d087 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -3311,6 +3311,13 @@ export class PositionController extends Controller { .orderBy("posMaster.posMasterOrder", "ASC") .getManyAndCount(); + const _posType = await this.posTypeRepository.find({ + where: { posTypeName: In(["ทั่วไป", "วิชาการ"]) } + }); + const _posLevel = await this.posLevelRepository.find({ + where: { posLevelName: In(["ปฏิบัติงาน", "ปฏิบัติการ"]) } + }); + const formattedData = await Promise.all( posMaster.map(async (posMaster) => { let shortName = ""; @@ -3375,6 +3382,49 @@ export class PositionController extends Controller { nodeId = posMaster.orgRootId; } + let _position: any + if( posLevel == null && posType == null && body.position != null) { + _position = posMaster.positions + .filter((x:any) => + _posType.some((y:any) => y.id == x.posTypeId) && + _posLevel.some((z:any) => z.id == x.posLevelId) + ) + .map((position) => ({ + id: position.id, + positionName: position.positionName, + positionField: position.positionField, + posTypeId: position.posTypeId, + posTypeName: position.posType == null ? null : position.posType.posTypeName, + posLevelId: position.posLevelId, + posLevelName: position.posLevel == null ? null : position.posLevel.posLevelName, + posExecutiveId: position.posExecutiveId, + posExecutiveName: + position.posExecutive == null ? null : position.posExecutive.posExecutiveName, + positionExecutiveField: position.positionExecutiveField, + positionArea: position.positionArea, + positionIsSelected: position.positionIsSelected, + isSpecial: position.isSpecial, + })); + } + else { + _position = posMaster.positions.map((position) => ({ + id: position.id, + positionName: position.positionName, + positionField: position.positionField, + posTypeId: position.posTypeId, + posTypeName: position.posType == null ? null : position.posType.posTypeName, + posLevelId: position.posLevelId, + posLevelName: position.posLevel == null ? null : position.posLevel.posLevelName, + posExecutiveId: position.posExecutiveId, + posExecutiveName: + position.posExecutive == null ? null : position.posExecutive.posExecutiveName, + positionExecutiveField: position.positionExecutiveField, + positionArea: position.positionArea, + positionIsSelected: position.positionIsSelected, + isSpecial: position.isSpecial, + })); + } + return { id: posMaster.id, node: node, @@ -3398,22 +3448,7 @@ export class PositionController extends Controller { ? null : `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`, isPosition: posMaster.positions.filter((x) => x.positionName == body.position).length > 0, - positions: posMaster.positions.map((position) => ({ - id: position.id, - positionName: position.positionName, - positionField: position.positionField, - posTypeId: position.posTypeId, - posTypeName: position.posType == null ? null : position.posType.posTypeName, - posLevelId: position.posLevelId, - posLevelName: position.posLevel == null ? null : position.posLevel.posLevelName, - posExecutiveId: position.posExecutiveId, - posExecutiveName: - position.posExecutive == null ? null : position.posExecutive.posExecutiveName, - positionExecutiveField: position.positionExecutiveField, - positionArea: position.positionArea, - positionIsSelected: position.positionIsSelected, - isSpecial: position.isSpecial, - })), + positions: _position, }; }), ); From 30df664aa7a36062fe245263387442702f54d51b Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 1 Nov 2024 15:50:52 +0700 Subject: [PATCH 2/2] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=20body=20=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1?= =?UTF-8?q?=E0=B9=88=E0=B8=8710?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandTypeController.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/controllers/CommandTypeController.ts b/src/controllers/CommandTypeController.ts index 22df0e3b..272aecf1 100644 --- a/src/controllers/CommandTypeController.ts +++ b/src/controllers/CommandTypeController.ts @@ -100,7 +100,7 @@ export class CommandTypeController extends Controller { */ @Get("{id}") async GetById(@Path() id: string) { - const _commandType = await this.commandTypeRepository.findOne({ + let _commandType = await this.commandTypeRepository.findOne({ where: { id }, select: [ "id", @@ -120,6 +120,28 @@ export class CommandTypeController extends Controller { if (!_commandType) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } + if(_commandType.code == "C-PM-10") { + let _commandType10: any + _commandType10 = { + id: _commandType.id, + name: _commandType.name, + commandSysId: _commandType.commandSysId, + code: _commandType.code, + fileCover: _commandType.fileCover, + fileAttachment: _commandType.fileAttachment, + isActive: _commandType.isActive, + detailHeader: _commandType.detailHeader, + detailBody: _commandType.detailBody, + detailFooter: _commandType.detailFooter, + subtitle: _commandType.subtitle, + isAttachment: _commandType.isAttachment, + name1: "..........................ประธาน", + name2: "..........................ผู้บังคับบัญชา", + name3: "..........................ผู้ดูแล", + name4: "..........................ผู้ดูแล", + } + _commandType = _commandType10; + } return new HttpSuccess(_commandType); }