From 71b618e3a83d30dc8787164211cf4bbc833c74f9 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Mon, 29 Jan 2024 10:23:58 +0700 Subject: [PATCH] checkpoint --- src/controllers/OrganizationController.ts | 61 ++++++++++++++++++++--- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index ea29d7b1..59ce46c0 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -21,6 +21,8 @@ import HttpSuccess from "../interfaces/http-success"; import { CreateOrgChild1, OrgChild1 } from "../entities/OrgChild1"; import HttpError from "../interfaces/http-error"; import HttpStatusCode from "../interfaces/http-status"; +import { createConnection } from "net"; +import { OrgRoot } from "../entities/OrgRoot"; @Route("api/v1/org") @Tags("Organization") @@ -120,13 +122,56 @@ export class OrganizationController extends Controller { * @summary ORG_023 - รายละเอียดโครงสร้าง (ADMIN) #25 * */ - // @Get() - // async detail(@Path() id: string) { - // try { + @Get("{id}") + async detail(@Path() id: string) { + + try { - // return new HttpSuccess(); - // } catch (error) { - // return error; - // } - // } + const orgRevisionData = await AppDataSource.getRepository(OrgRevision) + .createQueryBuilder("orgRevision") + // .leftJoin("orgRevision.orgRoots", "orgRoot") + // .leftJoin("orgRoot.orgChild1s", "orgChild1") + // .leftJoin("orgChild1.orgChild2s", "orgChild2") + // .leftJoin("orgChild2.orgChild3s", "orgChild3") + // .leftJoin("orgChild3.orgChild4s", "orgChild4") + .where("orgRevision.id = :id", { id }) + // .select([ + // "orgRoot.id", + // "orgRoot.orgRootName", + // "orgRoot.orgRootShortName", + // "orgRoot.orgRootCode", + // "orgRoot.orgRootOrder", + + // "orgChild1.id", + // "orgChild1.orgChild1Name", + // "orgChild1.orgChild1ShortName", + // "orgChild1.orgChild1Code", + // "orgChild1.orgChild1Order", + + // "orgChild2.id", + // "orgChild2.orgChild2Name", + // "orgChild2.orgChild2ShortName", + // "orgChild2.orgChild2Code", + // "orgChild2.orgChild2Order", + + // "orgChild3.id", + // "orgChild3.orgChild3Name", + // "orgChild3.orgChild3ShortName", + // "orgChild3.orgChild3Code", + // "orgChild3.orgChild3Order", + + // "orgChild4.id", + // "orgChild4.orgChild4Name", + // "orgChild4.orgChild4ShortName", + // "orgChild4.orgChild4Code", + // "orgChild4.orgChild4Order", + // ]) + .getOne(); + + + return new HttpSuccess(orgRevisionData); + } catch (error) { + return error; + } + } }