diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 04a2fa7e..edbd1f97 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -2036,7 +2036,7 @@ export class OrganizationController extends Controller { _data.child2 = [holder.orgChild2Id]; _data.child3 = [holder.orgChild3Id]; _data.child4 = [holder.orgChild4Id]; - } else if (_privilege.privilege == "CHILD") { + } else if (_privilege.privilege == "CHILD" || _privilege.privilege == "BROTHER") { const holder = profile.current_holders.find((x) => x.orgRevisionId === id); if (!holder) return; _data.root = [holder.orgRootId]; @@ -6174,7 +6174,7 @@ export class OrganizationController extends Controller { _data.child2 = [holder.orgChild2Id]; _data.child3 = [holder.orgChild3Id]; _data.child4 = [holder.orgChild4Id]; - } else if (_privilege.privilege == "CHILD") { + } else if (_privilege.privilege == "CHILD" || _privilege.privilege == "BROTHER") { const holder = profile.current_holders.find((x) => x.orgRevisionId === id); if (!holder) return; _data.root = [holder.orgRootId]; diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index cbae3874..00eb9b5a 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -79,7 +79,7 @@ export class OrganizationDotnetController extends Controller { ) { let condition = "1=1"; let conditionParams = {}; - if (body.role === "CHILD") { + if (body.role === "CHILD" || body.role === "BROTHER") { switch (body.node) { case 0: condition = "orgRoot.ancestorDNA = :nodeId"; @@ -198,7 +198,7 @@ export class OrganizationDotnetController extends Controller { ) { let condition = "1=1"; let conditionParams = {}; - if (body.role === "CHILD") { + if (body.role === "CHILD" || body.role === "BROTHER") { switch (body.node) { case 0: condition = "orgRoot.ancestorDNA = :nodeId"; @@ -4399,8 +4399,8 @@ export class OrganizationDotnetController extends Controller { }, ) { let typeCondition: any = {}; - if (body.role === "CHILD" || body.role === "PARENT") { - if (body.role === "CHILD") { + if (body.role === "CHILD" || body.role === "PARENT" || body.role === "BROTHER") { + if (body.role === "CHILD" || body.role === "BROTHER") { switch (body.node) { case 0: typeCondition = { @@ -4441,16 +4441,14 @@ export class OrganizationDotnetController extends Controller { typeCondition = {}; break; } - } - else if (body.role === "PARENT") { + } else if (body.role === "PARENT") { typeCondition = { orgRoot: { - ancestorDNA: body.nodeId + ancestorDNA: body.nodeId, }, orgChild1: Not(IsNull()), }; } - } else if (body.role === "OWNER" || body.role === "ROOT") { switch (body.reqNode) { case 0: @@ -5005,8 +5003,8 @@ export class OrganizationDotnetController extends Controller { }, ) { let typeCondition: any = {}; - if (body.role === "CHILD" || body.role === "PARENT") { - if (body.role === "CHILD") { + if (body.role === "CHILD" || body.role === "PARENT" || body.role === "BROTHER") { + if (body.role === "CHILD" || body.role === "BROTHER") { switch (body.node) { case 0: typeCondition = { @@ -5043,23 +5041,18 @@ export class OrganizationDotnetController extends Controller { }, }; break; - case null: - typeCondition = {}; - break; default: typeCondition = {}; break; } - } - else if (body.role === "PARENT") { + } else if (body.role === "PARENT") { typeCondition = { orgRoot: { - ancestorDNA: body.nodeId + ancestorDNA: body.nodeId, }, orgChild1: Not(IsNull()), }; } - } else if (body.role === "OWNER" || body.role === "ROOT") { switch (body.reqNode) { case 0: diff --git a/src/controllers/PermissionController.ts b/src/controllers/PermissionController.ts index 4cd20c8b..b082f0fd 100644 --- a/src/controllers/PermissionController.ts +++ b/src/controllers/PermissionController.ts @@ -748,6 +748,14 @@ export class PermissionController extends Controller { child3: node >= 3 ? [x.orgChild3Id] : null, child4: node >= 4 ? [x.orgChild4Id] : null, }; + } else if (privilege == "BROTHER") { + data = { + // root: node >= 0 ? null : null, + root: node >= 0 ? [x.orgRootId] : null, + child1: node >= 2 ? [x.orgChild1Id] : null, + child2: node >= 3 ? [x.orgChild2Id] : null, + child3: node >= 4 ? [x.orgChild3Id] : null, + }; } else if (privilege == "NORMAL") { data = { root: [x.orgRootId], diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 84144021..d2c5fc87 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -2525,7 +2525,11 @@ export class PositionController extends Controller { }), ); - if (_data.privilege === "NORMAL" || _data.privilege === "CHILD") { + if ( + _data.privilege === "NORMAL" || + _data.privilege === "CHILD" || + _data.privilege === "BROTHER" + ) { //PARENT จะไม่มีทางเห็น ROOT , CHILD ยึดจาก CHILD ที่อยู่ลงไปข้างล่างและจะไม่เห็น CHILD ที่อยู่เหนือกว่า const nextChildMap: any = { //เอาไวเช็ค CHILD ถัดไป @@ -2539,7 +2543,7 @@ export class PositionController extends Controller { if (Array.isArray(childValue) && childValue.some((item) => item != null)) { return new HttpSuccess({ data: [], total: 0 }); } - } else if (_data.privilege === "CHILD") { + } else if (_data.privilege === "CHILD" || _data.privilege === "BROTHER") { const higherChildChecks = [ { type: [0], child: _data.child1, next: _data.child2 }, { type: [0, 1], child: _data.child2, next: _data.child3 }, diff --git a/src/interfaces/permission.ts b/src/interfaces/permission.ts index b48478dc..1542ce45 100644 --- a/src/interfaces/permission.ts +++ b/src/interfaces/permission.ts @@ -112,6 +112,15 @@ class CheckAuth { child4: node >= 4 ? [x.orgChild4Id] : null, privilege: "CHILD", }; + } else if (privilege == "BROTHER") { + data = { + // root: node >= 0 ? [x.orgRootId] : null, + root: node >= 0 ? [x.orgRootId] : null, + child1: node >= 2 ? [x.orgChild1Id] : null, + child2: node >= 3 ? [x.orgChild2Id] : null, + child3: node >= 4 ? [x.orgChild3Id] : null, + privilege: "BROTHER", + }; } else if (privilege == "NORMAL") { data = { root: [x.orgRootId],