From 22c90279649f2f3749bc37cc15c04d858162dc73 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 19 Feb 2025 16:36:47 +0700 Subject: [PATCH] no message --- src/controllers/WorkflowController.ts | 48 +++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index a92e188a..c1318d1a 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -1,4 +1,4 @@ -import { Body, Controller, Get, Path, Post, Put, Request, Route, Security, Tags } from "tsoa"; +import { Body, Controller, Get, Path, Post, Put, Request, Route, Security, Tags, } from "tsoa"; import { AppDataSource } from "../database/data-source"; import { RequestWithUser } from "../middlewares/user"; import HttpError from "../interfaces/http-error"; @@ -15,7 +15,7 @@ import { MetaWorkflow } from "../entities/MetaWorkflow"; import { MetaState } from "../entities/MetaState"; import { MetaStateOperator } from "../entities/MetaStateOperator"; import { PosMaster } from "../entities/PosMaster"; -import { Brackets, IsNull, Not } from "typeorm"; +import { Brackets, IsNull, Not, In } from "typeorm"; import { Assign } from "../entities/Assign"; import { PosMasterAct } from "../entities/PosMasterAct"; import { viewDirectorActing } from "../entities/view/viewDirectorActing"; @@ -1143,4 +1143,48 @@ export class WorkflowController extends Controller { if (!profileOfficer) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลสิทธิ์"); return new HttpSuccess(); } + + /** + * API เช็ค สกจ + * + * @summary เช็ค สกจ + * + */ + @Post("find/director") + async getProfileDirectorByProfileId(@Request() req: RequestWithUser, + @Body() + body: { + system: string; + refId: string[]; + },) { + const _posMaster = await this.posMasterRepo.find({ + where: { + posMasterAssigns: { assignId: body.system }, + orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, + current_holderId: In(body.refId), + }, + select:["orgRootId","orgChild1Id","orgChild2Id","orgChild3Id","orgChild4Id"] + }); + const _data:any = _posMaster.map((x) => ({ + orgRootId: x.orgRootId, + orgChild1Id: x.orgChild1Id, + orgChild2Id: x.orgChild2Id, + orgChild3Id: x.orgChild3Id, + orgChild4Id: x.orgChild4Id, + director: true, + })); + const posMaster = await this.posMasterRepo.find({ + where: _data, + relations:["current_holder"] + }); + + const data = posMaster.map((x) => ({ + id: x.current_holder.id, + citizenId: x.current_holder.citizenId, + prefix: x.current_holder.prefix, + firstName: x.current_holder.firstName, + lastName: x.current_holder.lastName, + })); + return new HttpSuccess(data); + } }