This commit is contained in:
kittapath 2025-01-11 11:53:38 +07:00
parent f59734d47b
commit ded2da6361

View file

@ -5468,11 +5468,15 @@ export class OrganizationController extends Controller {
* *
*/ */
@Post("find/node-all") @Post("find/node-all")
async findNodeAllOrg(@Body() requestBody: { node: number; nodeId: string }) { async findNodeAllOrg(@Body() requestBody: { node: number; nodeId: string; isRoot: boolean }) {
let orgRootRankSub = ["DISTRICT"];
if (requestBody.isRoot == true) {
orgRootRankSub = ["BUREAU", "OFFICE"];
}
switch (requestBody.node) { switch (requestBody.node) {
case 0: { case 0: {
const data = await this.orgRootRepository.find({ const data = await this.orgRootRepository.find({
where: { id: requestBody.nodeId }, where: { id: requestBody.nodeId, orgRootRankSub: In(orgRootRankSub) },
}); });
return new HttpSuccess( return new HttpSuccess(
data.map((y) => ({ data.map((y) => ({
@ -5485,30 +5489,30 @@ export class OrganizationController extends Controller {
})), })),
); );
} }
case 1: { // case 1: {
const data = await this.child1Repository.find({ // const data = await this.child1Repository.find({
where: { id: requestBody.nodeId }, // where: { id: requestBody.nodeId },
}); // });
return new HttpSuccess(data); // return new HttpSuccess(data);
} // }
case 2: { // case 2: {
const data = await this.child2Repository.find({ // const data = await this.child2Repository.find({
where: { id: requestBody.nodeId }, // where: { id: requestBody.nodeId },
}); // });
return new HttpSuccess(data); // return new HttpSuccess(data);
} // }
case 3: { // case 3: {
const data = await this.child3Repository.find({ // const data = await this.child3Repository.find({
where: { id: requestBody.nodeId }, // where: { id: requestBody.nodeId },
}); // });
return new HttpSuccess(data); // return new HttpSuccess(data);
} // }
case 4: { // case 4: {
const data = await this.child4Repository.find({ // const data = await this.child4Repository.find({
where: { id: requestBody.nodeId }, // where: { id: requestBody.nodeId },
}); // });
return new HttpSuccess(data); // return new HttpSuccess(data);
} // }
default: { default: {
const data = await this.orgRootRepository.find({ const data = await this.orgRootRepository.find({
where: { where: {
@ -5516,6 +5520,7 @@ export class OrganizationController extends Controller {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
}, },
orgRootRankSub: In(orgRootRankSub),
}, },
}); });
return new HttpSuccess( return new HttpSuccess(
@ -5528,7 +5533,6 @@ export class OrganizationController extends Controller {
child4Id: null, child4Id: null,
})), })),
); );
return new HttpSuccess(data);
} }
} }
} }