ปรับ api => find/node-all
This commit is contained in:
parent
b5506eec04
commit
5a1b328d94
1 changed files with 80 additions and 39 deletions
|
|
@ -5469,36 +5469,53 @@ export class OrganizationController extends Controller {
|
|||
*/
|
||||
@Post("find/node-all")
|
||||
async findNodeAllOrg(
|
||||
@Body() requestBody: { node: number | null; nodeId: string | null; isRoot: boolean },
|
||||
@Body() requestBody: { node: number | null; nodeId: string | null },
|
||||
) {
|
||||
let orgRootRankSub = ["DISTRICT"];
|
||||
if (requestBody.isRoot == true) {
|
||||
orgRootRankSub = ["BUREAU", "OFFICE"];
|
||||
}
|
||||
let orgRootRankSub1 = ["BUREAU", "OFFICE"];
|
||||
let orgRootRankSub2 = [ "DISTRICT"];
|
||||
let data1:any
|
||||
let data2:any
|
||||
switch (requestBody.node) {
|
||||
case 0: {
|
||||
const data = await this.orgRootRepository.find({
|
||||
where: {
|
||||
const _data1 = await this.orgRootRepository.find({
|
||||
where: {
|
||||
id: requestBody.nodeId ?? "",
|
||||
orgRootRankSub: In(orgRootRankSub),
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
}
|
||||
orgRootRankSub: In(orgRootRankSub1)
|
||||
},
|
||||
order: { orgRootOrder: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(
|
||||
data.map((y) => ({
|
||||
name: y.orgRootName,
|
||||
rootId: y.id,
|
||||
child1Id: null,
|
||||
child2Id: null,
|
||||
child3Id: null,
|
||||
child4Id: null,
|
||||
})),
|
||||
);
|
||||
const _data2 = await this.orgRootRepository.find({
|
||||
where: [
|
||||
{
|
||||
id: requestBody.nodeId ?? "",
|
||||
orgRootRankSub: In(orgRootRankSub2)
|
||||
},
|
||||
{
|
||||
id: requestBody.nodeId ?? "",
|
||||
orgRootRankSub: IsNull()
|
||||
}
|
||||
],
|
||||
order: { orgRootOrder: "ASC" },
|
||||
});
|
||||
data1 = _data1.map((y) => ({
|
||||
name: y.orgRootName,
|
||||
rootId: y.id,
|
||||
child1Id: null,
|
||||
child2Id: null,
|
||||
child3Id: null,
|
||||
child4Id: null,
|
||||
}));
|
||||
data2 = _data2.map((y) => ({
|
||||
name: y.orgRootName,
|
||||
rootId: y.id,
|
||||
child1Id: null,
|
||||
child2Id: null,
|
||||
child3Id: null,
|
||||
child4Id: null,
|
||||
}));
|
||||
break;
|
||||
}
|
||||
// case 1: {
|
||||
// case 1: {
|
||||
// const data = await this.child1Repository.find({
|
||||
// where: { id: requestBody.nodeId },
|
||||
// });
|
||||
|
|
@ -5523,27 +5540,51 @@ export class OrganizationController extends Controller {
|
|||
// return new HttpSuccess(data);
|
||||
// }
|
||||
default: {
|
||||
const data = await this.orgRootRepository.find({
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
orgRootRankSub: In(orgRootRankSub),
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
});
|
||||
return new HttpSuccess(
|
||||
data.map((y) => ({
|
||||
name: y.orgRootName,
|
||||
rootId: y.id,
|
||||
child1Id: null,
|
||||
child2Id: null,
|
||||
child3Id: null,
|
||||
child4Id: null,
|
||||
})),
|
||||
);
|
||||
const _data1 = await this.orgRootRepository.find({
|
||||
where: {
|
||||
orgRevisionId: orgRevision?.id,
|
||||
orgRootRankSub: In(orgRootRankSub1),
|
||||
},
|
||||
order: { orgRootOrder: "ASC" },
|
||||
});
|
||||
const _data2 = await this.orgRootRepository.find({
|
||||
where: [
|
||||
{
|
||||
orgRevisionId: orgRevision?.id,
|
||||
orgRootRankSub: In(orgRootRankSub2),
|
||||
},
|
||||
{
|
||||
orgRevisionId: orgRevision?.id,
|
||||
orgRootRankSub: IsNull(),
|
||||
},
|
||||
],
|
||||
order: { orgRootOrder: "ASC" },
|
||||
});
|
||||
data1 = _data1.map((y) => ({
|
||||
name: y.orgRootName,
|
||||
rootId: y.id,
|
||||
child1Id: null,
|
||||
child2Id: null,
|
||||
child3Id: null,
|
||||
child4Id: null,
|
||||
}));
|
||||
data2 = _data2.map((y) => ({
|
||||
name: y.orgRootName,
|
||||
rootId: y.id,
|
||||
child1Id: null,
|
||||
child2Id: null,
|
||||
child3Id: null,
|
||||
child4Id: null,
|
||||
}));
|
||||
}
|
||||
}
|
||||
return new HttpSuccess({isRootTrue: data1, isRootFalse: data2})
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue