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 *