diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index af07af72..c8958239 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -3570,18 +3570,19 @@ 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, - }; - - if (!request.user.role.includes("SUPER_ADMIN")) { - _data = await new permission().PermissionOrgList(request, "SYS_ACTING"); - } - + // 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"); + // } + await new permission().PermissionOrgList(request, "SYS_ACTING"); + const orgRevision = await this.orgRevisionRepository.findOne({ where: { id } }); if (!orgRevision) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); @@ -3590,16 +3591,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") @@ -3611,16 +3612,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") @@ -3633,16 +3634,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") @@ -3655,16 +3656,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") @@ -3677,16 +3678,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: [