api รายละเอัยดกิ่งหน่วยงาน
This commit is contained in:
parent
e87c7a85ab
commit
d431bbaf3a
1 changed files with 127 additions and 0 deletions
|
|
@ -2835,6 +2835,133 @@ export class OrganizationController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API เช็ค node detail
|
||||
*
|
||||
* @summary เช็ค node detail (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Post("find/all")
|
||||
async findNodeAllDetail(@Body() requestBody: { node: number; nodeId: string }) {
|
||||
switch (requestBody.node) {
|
||||
case 0: {
|
||||
const data = await this.orgRootRepository.findOne({
|
||||
where: { id: requestBody.nodeId },
|
||||
});
|
||||
if (data == null) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found rootId.");
|
||||
}
|
||||
return new HttpSuccess({
|
||||
rootId: data.id,
|
||||
root: data.orgRootName,
|
||||
rootShortName: data.orgRootShortName,
|
||||
});
|
||||
}
|
||||
case 1: {
|
||||
const data = await this.child1Repository.findOne({
|
||||
where: { id: requestBody.nodeId },
|
||||
relations: {
|
||||
orgRoot: true,
|
||||
},
|
||||
});
|
||||
if (data == null) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found child1.");
|
||||
}
|
||||
return new HttpSuccess({
|
||||
rootId: data.orgRootId,
|
||||
root: data.orgRoot == null ? null : data.orgRoot.orgRootName,
|
||||
rootShortName: data.orgRoot == null ? null : data.orgRoot.orgRootShortName,
|
||||
child1Id: data.id,
|
||||
child1: data.orgChild1Name,
|
||||
child1ShortName: data.orgChild1ShortName,
|
||||
});
|
||||
}
|
||||
case 2: {
|
||||
const data = await this.child2Repository.findOne({
|
||||
where: { id: requestBody.nodeId },
|
||||
relations: {
|
||||
orgRoot: true,
|
||||
orgChild1: true,
|
||||
},
|
||||
});
|
||||
if (data == null) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found child2.");
|
||||
}
|
||||
return new HttpSuccess({
|
||||
rootId: data.orgRootId,
|
||||
root: data.orgRoot == null ? null : data.orgRoot.orgRootName,
|
||||
rootShortName: data.orgRoot == null ? null : data.orgRoot.orgRootShortName,
|
||||
child1Id: data.orgChild1Id,
|
||||
child1: data.orgChild1 == null ? null : data.orgChild1.orgChild1Name,
|
||||
child1ShortName: data.orgChild1 == null ? null : data.orgChild1.orgChild1ShortName,
|
||||
child2Id: data.id,
|
||||
child2: data.orgChild2Name,
|
||||
child2ShortName: data.orgChild2ShortName,
|
||||
});
|
||||
}
|
||||
case 3: {
|
||||
const data = await this.child3Repository.findOne({
|
||||
where: { id: requestBody.nodeId },
|
||||
relations: {
|
||||
orgRoot: true,
|
||||
orgChild1: true,
|
||||
orgChild2: true,
|
||||
},
|
||||
});
|
||||
if (data == null) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found child3.");
|
||||
}
|
||||
return new HttpSuccess({
|
||||
rootId: data.orgRootId,
|
||||
root: data.orgRoot == null ? null : data.orgRoot.orgRootName,
|
||||
rootShortName: data.orgRoot == null ? null : data.orgRoot.orgRootShortName,
|
||||
child1Id: data.orgChild1Id,
|
||||
child1: data.orgChild1 == null ? null : data.orgChild1.orgChild1Name,
|
||||
child1ShortName: data.orgChild1 == null ? null : data.orgChild1.orgChild1ShortName,
|
||||
child2Id: data.orgChild2Id,
|
||||
child2: data.orgChild2 == null ? null : data.orgChild2.orgChild2Name,
|
||||
child2ShortName: data.orgChild2 == null ? null : data.orgChild2.orgChild2ShortName,
|
||||
child3Id: data.id,
|
||||
child3: data.orgChild3Name,
|
||||
child3ShortName: data.orgChild3ShortName,
|
||||
});
|
||||
}
|
||||
case 4: {
|
||||
const data = await this.child4Repository.findOne({
|
||||
where: { id: requestBody.nodeId },
|
||||
relations: {
|
||||
orgRoot: true,
|
||||
orgChild1: true,
|
||||
orgChild2: true,
|
||||
orgChild3: true,
|
||||
},
|
||||
});
|
||||
if (data == null) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found child4.");
|
||||
}
|
||||
return new HttpSuccess({
|
||||
rootId: data.orgRootId,
|
||||
root: data.orgRoot == null ? null : data.orgRoot.orgRootName,
|
||||
rootShortName: data.orgRoot == null ? null : data.orgRoot.orgRootShortName,
|
||||
child1Id: data.orgChild1Id,
|
||||
child1: data.orgChild1 == null ? null : data.orgChild1.orgChild1Name,
|
||||
child1ShortName: data.orgChild1 == null ? null : data.orgChild1.orgChild1ShortName,
|
||||
child2Id: data.orgChild2Id,
|
||||
child2: data.orgChild2 == null ? null : data.orgChild2.orgChild2Name,
|
||||
child2ShortName: data.orgChild2 == null ? null : data.orgChild2.orgChild2ShortName,
|
||||
child3Id: data.orgChild3Id,
|
||||
child3: data.orgChild3 == null ? null : data.orgChild3.orgChild3Name,
|
||||
child3ShortName: data.orgChild3 == null ? null : data.orgChild3.orgChild3ShortName,
|
||||
child4Id: data.id,
|
||||
child4: data.orgChild4Name,
|
||||
child4ShortName: data.orgChild4ShortName,
|
||||
});
|
||||
}
|
||||
default:
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found type: " + requestBody.node);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API หาสำนักทั้งหมด
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue