From 25690f222ed3cfde1394d73fe78eed8e141e74d0 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 6 Sep 2024 11:58:55 +0700 Subject: [PATCH] =?UTF-8?q?fix=20=E0=B9=80=E0=B8=A1=E0=B8=99=E0=B8=B9?= =?UTF-8?q?=E0=B8=A3=E0=B8=B1=E0=B8=81=E0=B8=A9=E0=B8=B2=E0=B8=81=E0=B8=B2?= =?UTF-8?q?=E0=B8=A3=E0=B9=81=E0=B8=97=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/OrganizationController.ts | 121 +++++++++++----------- src/controllers/PositionController.ts | 26 +---- 2 files changed, 62 insertions(+), 85 deletions(-) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index ecc18656..12c88709 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -3561,17 +3561,18 @@ export class OrganizationController extends Controller { */ @Get("act/{id}") async detailAct(@Path() id: string, @Request() request: RequestWithUser) { - let _data = { - root: null, - child1: null, - child2: null, - child3: null, - child4: null, - }; + // let _data = { + // root: null, + // child1: null, + // child2: null, + // child3: null, + // child4: null, + // }; - if (!request.user.role.includes("SUPER_ADMIN")) { - _data = await new permission().PermissionOrgList(request, "SYS_ACTING"); - } + // if (!request.user.role.includes("SUPER_ADMIN")) { + // _data = await new permission().PermissionOrgList(request, "SYS_ACTING"); + // } + await new permission().PermissionOrgList(request, "SYS_ACTING"); const orgRevision = await this.orgRevisionRepository.findOne({ where: { id } }); if (!orgRevision) { @@ -3581,16 +3582,16 @@ export class OrganizationController extends Controller { const orgRootData = await AppDataSource.getRepository(OrgRoot) .createQueryBuilder("orgRoot") .where("orgRoot.orgRevisionId = :id", { id }) - .andWhere( - _data.root != undefined && _data.root != null - ? _data.root[0] != null - ? `orgRoot.id IN (:...node)` - : `orgRoot.id is null` - : "1=1", - { - node: _data.root, - }, - ) + // .andWhere( + // _data.root != undefined && _data.root != null + // ? _data.root[0] != null + // ? `orgRoot.id IN (:...node)` + // : `orgRoot.id is null` + // : "1=1", + // { + // node: _data.root, + // }, + // ) .leftJoinAndSelect("orgRoot.posMasters", "posMasters") .leftJoinAndSelect("posMasters.current_holder", "current_holder") .orderBy("orgRoot.orgRootOrder", "ASC") @@ -3602,16 +3603,16 @@ export class OrganizationController extends Controller { ? await AppDataSource.getRepository(OrgChild1) .createQueryBuilder("orgChild1") .where("orgChild1.orgRootId IN (:...ids)", { ids: orgRootIds }) - .andWhere( - _data.child1 != undefined && _data.child1 != null - ? _data.child1[0] != null - ? `orgChild1.id IN (:...node)` - : `orgChild1.id is null` - : "1=1", - { - node: _data.child1, - }, - ) + // .andWhere( + // _data.child1 != undefined && _data.child1 != null + // ? _data.child1[0] != null + // ? `orgChild1.id IN (:...node)` + // : `orgChild1.id is null` + // : "1=1", + // { + // node: _data.child1, + // }, + // ) .leftJoinAndSelect("orgChild1.posMasters", "posMasters") .leftJoinAndSelect("posMasters.current_holder", "current_holder") .orderBy("orgChild1.orgChild1Order", "ASC") @@ -3624,16 +3625,16 @@ export class OrganizationController extends Controller { ? await AppDataSource.getRepository(OrgChild2) .createQueryBuilder("orgChild2") .where("orgChild2.orgChild1Id IN (:...ids)", { ids: orgChild1Ids }) - .andWhere( - _data.child2 != undefined && _data.child2 != null - ? _data.child2[0] != null - ? `orgChild2.id IN (:...node)` - : `orgChild2.id is null` - : "1=1", - { - node: _data.child2, - }, - ) + // .andWhere( + // _data.child2 != undefined && _data.child2 != null + // ? _data.child2[0] != null + // ? `orgChild2.id IN (:...node)` + // : `orgChild2.id is null` + // : "1=1", + // { + // node: _data.child2, + // }, + // ) .leftJoinAndSelect("orgChild2.posMasters", "posMasters") .leftJoinAndSelect("posMasters.current_holder", "current_holder") .orderBy("orgChild2.orgChild2Order", "ASC") @@ -3646,16 +3647,16 @@ export class OrganizationController extends Controller { ? await AppDataSource.getRepository(OrgChild3) .createQueryBuilder("orgChild3") .where("orgChild3.orgChild2Id IN (:...ids)", { ids: orgChild2Ids }) - .andWhere( - _data.child3 != undefined && _data.child3 != null - ? _data.child3[0] != null - ? `orgChild3.id IN (:...node)` - : `orgChild3.id is null` - : "1=1", - { - node: _data.child3, - }, - ) + // .andWhere( + // _data.child3 != undefined && _data.child3 != null + // ? _data.child3[0] != null + // ? `orgChild3.id IN (:...node)` + // : `orgChild3.id is null` + // : "1=1", + // { + // node: _data.child3, + // }, + // ) .leftJoinAndSelect("orgChild3.posMasters", "posMasters") .leftJoinAndSelect("posMasters.current_holder", "current_holder") .orderBy("orgChild3.orgChild3Order", "ASC") @@ -3668,16 +3669,16 @@ export class OrganizationController extends Controller { ? await AppDataSource.getRepository(OrgChild4) .createQueryBuilder("orgChild4") .where("orgChild4.orgChild3Id IN (:...ids)", { ids: orgChild3Ids }) - .andWhere( - _data.child4 != undefined && _data.child4 != null - ? _data.child4[0] != null - ? `orgChild4.id IN (:...node)` - : `orgChild4.id is null` - : "1=1", - { - node: _data.child4, - }, - ) + // .andWhere( + // _data.child4 != undefined && _data.child4 != null + // ? _data.child4[0] != null + // ? `orgChild4.id IN (:...node)` + // : `orgChild4.id is null` + // : "1=1", + // { + // node: _data.child4, + // }, + // ) .leftJoinAndSelect("orgChild4.posMasters", "posMasters") .leftJoinAndSelect("posMasters.current_holder", "current_holder") .orderBy("orgChild4.orgChild4Order", "ASC") diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index f33dabe3..9626a20a 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -3321,18 +3321,7 @@ export class PositionController extends Controller { isAll: boolean; }, ) { - // let _data = { - // root: null, - // child1: null, - // child2: null, - // child3: null, - // child4: null, - // } - - // if (!request.user.role.includes("SUPER_ADMIN")) { - // _data = await new permission().PermissionOrgList(request, "SYS_ORG"); - // } - + await new permission().PermissionGet(request,"SYS_ACTING"); const posMasterMain = await this.posMasterRepository.findOne({ where: { id: body.posmasterId }, relations: ["posMasterActs"], @@ -3363,21 +3352,8 @@ export class PositionController extends Controller { current_holderId: Not(IsNull()), id: Not(In(posId)), }; - // console.log("ddddd",_data); - - // typeCondition = { - // orgRoot: _data.root && _data.root[0] ? { id: In(_data.root) } : { id: IsNull() }, - // orgChild1: _data.child1 && _data.child1[0] ? { id: In(_data.child1) } : { id: IsNull() }, - // orgChild2: _data.child2 && _data.child2[0] ? { id: In(_data.child2) } : { id: IsNull() }, - // orgChild3: _data.child3 && _data.child3[0] ? { id: In(_data.child3) } : { id: IsNull() }, - // orgChild4: _data.child4 && _data.child4[0] ? { id: In(_data.child4) } : { id: IsNull() }, - // current_holderId: Not(IsNull()), - // id: Not(In(posId)), - // }; } - // console.log("typeCondition>>>",typeCondition); - const posMaster = await this.posMasterRepository.find({ where: typeCondition, relations: [