This commit is contained in:
kittapath 2025-02-05 15:38:21 +07:00
parent 4aae619e90
commit b0b1e06a78
5 changed files with 350 additions and 38 deletions

View file

@ -5522,45 +5522,273 @@ export class OrganizationController extends Controller {
rootId: y.id,
rootDnaId: y.ancestorDNA,
child1Id: null,
child1DnaId: null,
child2Id: null,
child2DnaId: null,
child3Id: null,
child3DnaId: null,
child4Id: null,
child4DnaId: null,
}));
data2 = _data2.map((y) => ({
name: y.orgRootName,
rootId: y.id,
rootDnaId: y.ancestorDNA,
child1Id: null,
child1DnaId: null,
child2Id: null,
child2DnaId: null,
child3Id: null,
child3DnaId: null,
child4Id: null,
child4DnaId: null,
}));
break;
}
case 1: {
const _data1 = await this.child1Repository.find({
where: {
id: requestBody.nodeId ?? "",
orgRoot: {
orgRootRankSub: In(orgRootRankSub1),
},
},
order: {
orgRoot: { orgRootOrder: "ASC" },
},
relations: ["orgRoot"],
});
const _data2 = await this.child1Repository.find({
where: [
{
id: requestBody.nodeId ?? "",
orgRoot: {
orgRootRankSub: In(orgRootRankSub2),
},
},
{
id: requestBody.nodeId ?? "",
orgRoot: {
orgRootRankSub: IsNull(),
},
},
],
order: {
orgRoot: { orgRootOrder: "ASC" },
},
relations: ["orgRoot"],
});
data1 = _data1.map((y) => ({
name: y.orgRoot.orgRootName,
rootId: y.orgRoot.id,
rootDnaId: y.orgRoot.ancestorDNA,
child1Id: y.id,
child1DnaId: y.ancestorDNA,
child2Id: null,
child2DnaId: null,
child3Id: null,
child3DnaId: null,
child4Id: null,
child4DnaId: null,
}));
data2 = _data2.map((y) => ({
name: y.orgRoot.orgRootName,
rootId: y.orgRoot.id,
rootDnaId: y.orgRoot.ancestorDNA,
child1Id: y.id,
child1DnaId: y.ancestorDNA,
child2Id: null,
child2DnaId: null,
child3Id: null,
child3DnaId: null,
child4Id: null,
child4DnaId: null,
}));
break;
}
case 2: {
const _data1 = await this.child2Repository.find({
where: {
id: requestBody.nodeId ?? "",
orgRoot: {
orgRootRankSub: In(orgRootRankSub1),
},
},
order: {
orgRoot: { orgRootOrder: "ASC" },
},
relations: ["orgRoot", "orgChild1"],
});
const _data2 = await this.child2Repository.find({
where: [
{
id: requestBody.nodeId ?? "",
orgRoot: {
orgRootRankSub: In(orgRootRankSub2),
},
},
{
id: requestBody.nodeId ?? "",
orgRoot: {
orgRootRankSub: IsNull(),
},
},
],
order: {
orgRoot: { orgRootOrder: "ASC" },
},
relations: ["orgRoot", "orgChild1"],
});
data1 = _data1.map((y) => ({
name: y.orgRoot.orgRootName,
rootId: y.orgRoot.id,
rootDnaId: y.orgRoot.ancestorDNA,
child1Id: y.orgChild1.id,
child1DnaId: y.orgChild1.ancestorDNA,
child2Id: y.id,
child2DnaId: y.ancestorDNA,
child3Id: null,
child3DnaId: null,
child4Id: null,
child4DnaId: null,
}));
data2 = _data2.map((y) => ({
name: y.orgRoot.orgRootName,
rootId: y.orgRoot.id,
rootDnaId: y.orgRoot.ancestorDNA,
child1Id: y.orgChild1.id,
child1DnaId: y.orgChild1.ancestorDNA,
child2Id: y.id,
child2DnaId: y.ancestorDNA,
child3Id: null,
child3DnaId: null,
child4Id: null,
child4DnaId: null,
}));
break;
}
case 3: {
const _data1 = await this.child3Repository.find({
where: {
id: requestBody.nodeId ?? "",
orgRoot: {
orgRootRankSub: In(orgRootRankSub1),
},
},
order: {
orgRoot: { orgRootOrder: "ASC" },
},
relations: ["orgRoot", "orgChild1", "orgChild2"],
});
const _data2 = await this.child3Repository.find({
where: [
{
id: requestBody.nodeId ?? "",
orgRoot: {
orgRootRankSub: In(orgRootRankSub2),
},
},
{
id: requestBody.nodeId ?? "",
orgRoot: {
orgRootRankSub: IsNull(),
},
},
],
order: {
orgRoot: { orgRootOrder: "ASC" },
},
relations: ["orgRoot", "orgChild1", "orgChild2"],
});
data1 = _data1.map((y) => ({
name: y.orgRoot.orgRootName,
rootId: y.orgRoot.id,
rootDnaId: y.orgRoot.ancestorDNA,
child1Id: y.orgChild1.id,
child1DnaId: y.orgChild1.ancestorDNA,
child2Id: y.orgChild2.id,
child2DnaId: y.orgChild2.ancestorDNA,
child3Id: y.id,
child3DnaId: y.ancestorDNA,
child4Id: null,
child4DnaId: null,
}));
data2 = _data2.map((y) => ({
name: y.orgRoot.orgRootName,
rootId: y.orgRoot.id,
rootDnaId: y.orgRoot.ancestorDNA,
child1Id: y.orgChild1.id,
child1DnaId: y.orgChild1.ancestorDNA,
child2Id: y.orgChild2.id,
child2DnaId: y.orgChild2.ancestorDNA,
child3Id: y.id,
child3DnaId: y.ancestorDNA,
child4Id: null,
child4DnaId: null,
}));
break;
}
case 4: {
const _data1 = await this.child4Repository.find({
where: {
id: requestBody.nodeId ?? "",
orgRoot: {
orgRootRankSub: In(orgRootRankSub1),
},
},
order: {
orgRoot: { orgRootOrder: "ASC" },
},
relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3"],
});
const _data2 = await this.child4Repository.find({
where: [
{
id: requestBody.nodeId ?? "",
orgRoot: {
orgRootRankSub: In(orgRootRankSub2),
},
},
{
id: requestBody.nodeId ?? "",
orgRoot: {
orgRootRankSub: IsNull(),
},
},
],
order: {
orgRoot: { orgRootOrder: "ASC" },
},
relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3"],
});
data1 = _data1.map((y) => ({
name: y.orgRoot.orgRootName,
rootId: y.orgRoot.id,
rootDnaId: y.orgRoot.ancestorDNA,
child1Id: y.orgChild1.id,
child1DnaId: y.orgChild1.ancestorDNA,
child2Id: y.orgChild2.id,
child2DnaId: y.orgChild2.ancestorDNA,
child3Id: y.orgChild3.id,
child3DnaId: y.orgChild3.ancestorDNA,
child4Id: y.id,
child4DnaId: y.ancestorDNA,
}));
data2 = _data2.map((y) => ({
name: y.orgRoot.orgRootName,
rootId: y.orgRoot.id,
rootDnaId: y.orgRoot.ancestorDNA,
child1Id: y.orgChild1.id,
child1DnaId: y.orgChild1.ancestorDNA,
child2Id: y.orgChild2.id,
child2DnaId: y.orgChild2.ancestorDNA,
child3Id: y.orgChild3.id,
child3DnaId: y.orgChild3.ancestorDNA,
child4Id: y.id,
child4DnaId: y.ancestorDNA,
}));
break;
}
// case 1: {
// const data = await this.child1Repository.find({
// where: { id: requestBody.nodeId },
// });
// return new HttpSuccess(data);
// }
// case 2: {
// const data = await this.child2Repository.find({
// where: { id: requestBody.nodeId },
// });
// return new HttpSuccess(data);
// }
// case 3: {
// const data = await this.child3Repository.find({
// where: { id: requestBody.nodeId },
// });
// return new HttpSuccess(data);
// }
// case 4: {
// const data = await this.child4Repository.find({
// where: { id: requestBody.nodeId },
// });
// return new HttpSuccess(data);
// }
default: {
const orgRevision = await this.orgRevisionRepository.findOne({
where: {
@ -5646,7 +5874,7 @@ export class OrganizationController extends Controller {
}
return new HttpSuccess({
rootId: data.orgRootId,
rootDnaId: data.ancestorDNA,
rootDnaId: data.orgRoot == null ? null : data.orgRoot.ancestorDNA,
root: data.orgRoot == null ? null : data.orgRoot.orgRootName,
rootShortName: data.orgRoot == null ? null : data.orgRoot.orgRootShortName,
child1Id: data.id,
@ -5668,11 +5896,11 @@ export class OrganizationController extends Controller {
}
return new HttpSuccess({
rootId: data.orgRootId,
rootDnaId: data.ancestorDNA,
rootDnaId: data.orgRoot == null ? null : data.orgRoot.ancestorDNA,
root: data.orgRoot == null ? null : data.orgRoot.orgRootName,
rootShortName: data.orgRoot == null ? null : data.orgRoot.orgRootShortName,
child1Id: data.orgChild1Id,
child1DnaId: data.ancestorDNA,
child1DnaId: data.orgChild1 == null ? null : data.orgChild1.ancestorDNA,
child1: data.orgChild1 == null ? null : data.orgChild1.orgChild1Name,
child1ShortName: data.orgChild1 == null ? null : data.orgChild1.orgChild1ShortName,
child2Id: data.id,
@ -5695,15 +5923,15 @@ export class OrganizationController extends Controller {
}
return new HttpSuccess({
rootId: data.orgRootId,
rootDnaId: data.ancestorDNA,
rootDnaId: data.orgRoot == null ? null : data.orgRoot.ancestorDNA,
root: data.orgRoot == null ? null : data.orgRoot.orgRootName,
rootShortName: data.orgRoot == null ? null : data.orgRoot.orgRootShortName,
child1Id: data.orgChild1Id,
child1DnaId: data.ancestorDNA,
child1DnaId: data.orgChild1 == null ? null : data.orgChild1.ancestorDNA,
child1: data.orgChild1 == null ? null : data.orgChild1.orgChild1Name,
child1ShortName: data.orgChild1 == null ? null : data.orgChild1.orgChild1ShortName,
child2Id: data.orgChild2Id,
child2DnaId: data.ancestorDNA,
child2DnaId: data.orgChild2 == null ? null : data.orgChild2.ancestorDNA,
child2: data.orgChild2 == null ? null : data.orgChild2.orgChild2Name,
child2ShortName: data.orgChild2 == null ? null : data.orgChild2.orgChild2ShortName,
child3Id: data.id,
@ -5727,19 +5955,19 @@ export class OrganizationController extends Controller {
}
return new HttpSuccess({
rootId: data.orgRootId,
rootDnaId: data.ancestorDNA,
rootDnaId: data.orgRoot == null ? null : data.orgRoot.ancestorDNA,
root: data.orgRoot == null ? null : data.orgRoot.orgRootName,
rootShortName: data.orgRoot == null ? null : data.orgRoot.orgRootShortName,
child1Id: data.orgChild1Id,
child1DnaId: data.ancestorDNA,
child1DnaId: data.orgChild1 == null ? null : data.orgChild1.ancestorDNA,
child1: data.orgChild1 == null ? null : data.orgChild1.orgChild1Name,
child1ShortName: data.orgChild1 == null ? null : data.orgChild1.orgChild1ShortName,
child2Id: data.orgChild2Id,
child2DnaId: data.ancestorDNA,
child2DnaId: data.orgChild2 == null ? null : data.orgChild2.ancestorDNA,
child2: data.orgChild2 == null ? null : data.orgChild2.orgChild2Name,
child2ShortName: data.orgChild2 == null ? null : data.orgChild2.orgChild2ShortName,
child3Id: data.orgChild3Id,
child3DnaId: data.ancestorDNA,
child3DnaId: data.orgChild3 == null ? null : data.orgChild3.ancestorDNA,
child3: data.orgChild3 == null ? null : data.orgChild3.orgChild3Name,
child3ShortName: data.orgChild3 == null ? null : data.orgChild3.orgChild3ShortName,
child4Id: data.id,