From c38eae7498e44164d497204118938ea65063dec9 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 13 Nov 2024 11:56:22 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=AB=E0=B8=B2=20root?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/OrganizationController.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index e1d78f9e..642bdee5 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -5520,6 +5520,27 @@ export class OrganizationController extends Controller { return new HttpSuccess(data.map((x) => x.id)); } + /** + * API หาสำนักทั้งหมด + * + * @summary หาสำนักทั้งหมด + * + */ + @Get("active/root/all") + async GetActiveRootAll() { + 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); + } + /** * API *