From 98cfe8f63995f37519c93facd977fb79aac4e135 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 28 Feb 2024 11:28:06 +0700 Subject: [PATCH] no message --- src/controllers/OrganizationController.ts | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 9ed4c139..899ed9a3 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -2864,6 +2864,31 @@ export class OrganizationController extends Controller { } } + /** + * API หาสำนักทั้งหมด + * + * @summary หาสำนักทั้งหมด + * + */ + @Get("active/root/id") + async GetActiveRootId() { + try { + const orgRevisionActive = await this.orgRevisionRepository.findOne({ + where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false }, + }); + if (!orgRevisionActive) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบโครงสร้างที่เผยแพร๋อยู่ตอนนี้"); + } + + const data = await this.orgRootRepository.find({ + where: { orgRevisionId: orgRevisionActive.id }, + }); + return new HttpSuccess(data.map((x) => x.id)); + } catch (error) { + return error; + } + } + /** * API หาสำนักทั้งหมด by revision *