From 9fdb2ef2e7d63bc238b42e65cc7f984cc3f2c118 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Thu, 12 Sep 2024 14:16:43 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=20parth=20api=20=E0=B9=83=E0=B8=8A=E0=B9=88=E0=B8=8B=E0=B9=89?= =?UTF-8?q?=E0=B8=B3=E0=B8=81=E0=B8=B1=E0=B8=99=E0=B9=83=E0=B8=99=E0=B8=AB?= =?UTF-8?q?=E0=B8=A5=E0=B8=B2=E0=B8=A2=E0=B9=80=E0=B8=A1=E0=B8=99=E0=B8=B9?= =?UTF-8?q?=20(=E0=B8=82=E0=B9=89=E0=B8=AD=E0=B8=A1=E0=B8=B9=E0=B8=A5?= =?UTF-8?q?=E0=B9=81=E0=B8=9A=E0=B8=9A=E0=B8=9B=E0=B8=99=E0=B8=B0=E0=B9=80?= =?UTF-8?q?=E0=B8=A1=E0=B8=B4=E0=B8=99>>>=E0=B8=95=E0=B8=B1=E0=B8=A7?= =?UTF-8?q?=E0=B8=8A=E0=B8=B5=E0=B9=89=E0=B8=A7=E0=B8=B1=E0=B8=94(?= =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=A5=E0=B8=B0=E0=B9=80=E0=B8=AD?= =?UTF-8?q?=E0=B8=B5=E0=B8=A2=E0=B8=94=E0=B9=81=E0=B8=A5=E0=B8=B0=E0=B9=81?= =?UTF-8?q?=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82=E0=B8=82=E0=B9=89=E0=B8=AD?= =?UTF-8?q?=E0=B8=A1=E0=B8=B9=E0=B8=A5))?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/StrategyController.ts | 50 +++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/controllers/StrategyController.ts b/src/controllers/StrategyController.ts index f0d781f..b4a03db 100644 --- a/src/controllers/StrategyController.ts +++ b/src/controllers/StrategyController.ts @@ -20,6 +20,55 @@ export class StrategyController extends Controller { private strategy3Repo = AppDataSource.getRepository(StrategyChild3); private strategy4Repo = AppDataSource.getRepository(StrategyChild4); private strategy5Repo = AppDataSource.getRepository(StrategyChild5); + + @Get("indicator") + public async listStrategyChild(@Request() request: RequestWithUser) { + let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR"); + const listStrategyChild1 = await this.strategy1Repo.find({ + relations: [ + "strategyChild2s", + "strategyChild2s.strategyChild3s", + "strategyChild2s.strategyChild3s.strategyChild4s", + "strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s", + ], + order: { createdAt: "ASC" }, + }); + + const formattedData = listStrategyChild1.map((item) => ({ + id: item.id, + level: 1, + name: item.strategyChild1Name, + children: item.strategyChild2s.map((child2) => ({ + id: child2.id, + level: 2, + name: child2.strategyChild2Name, + children: child2.strategyChild3s + ? child2.strategyChild3s.map((child3) => ({ + id: child3.id, + level: 3, + name: child3.strategyChild3Name, + children: child3.strategyChild4s + ? child3.strategyChild4s.map((child4) => ({ + id: child4.id, + level: 4, + name: child4.strategyChild4Name, + children: child4.strategyChild5s + ? child4.strategyChild5s.map((child5) => ({ + id: child5.id, + level: 5, + name: child5.strategyChild5Name, + })) + : [], + })) + : [], + })) + : [], + })), + })); + + return new HttpSuccess(formattedData); + } + @Get("edit") public async listStrategyChild1Edit(@Request() request: RequestWithUser) { let _data = await new permission().PermissionList(request, "SYS_EVA_STRATIGIC"); @@ -71,6 +120,7 @@ export class StrategyController extends Controller { return new HttpSuccess(formattedData); } + @Get() public async listStrategyChild1(@Request() request: RequestWithUser) { const listStrategyChild1 = await this.strategy1Repo.find({