เพิ่มselect detail tree

This commit is contained in:
Kittapath 2024-01-31 18:24:38 +07:00
parent 35ba5b91f3
commit cd21c42710
7 changed files with 175 additions and 147 deletions

View file

@ -46,17 +46,18 @@ export class OrgChild3Controller {
*/
@Get("{id}")
async GetChild3(@Path() id: string) {
const orgChild3 = await this.child3Repository.findOne({ where: { id } });
const orgChild3 = await this.child3Repository.findOne({
where: { id },
relations: ["orgRoot", "orgChild1", "orgChild2"],
});
if (!orgChild3) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล โครงสร้างระดับ 3");
}
const orgRoot = await this.orgRootRepository.findOne({ where: { id: orgChild3.orgRootId } });
if (!orgRoot) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล โครงสร้างระดับ Root");
}
try {
const getOrgChild3 = {
orgChild3Id: orgChild3.id,
orgRootName: orgChild3.orgRoot.orgRootName,
orgName: `${orgChild3.orgChild3Name}/${orgChild3.orgChild2.orgChild2Name}/${orgChild3.orgChild1.orgChild1Name}/${orgChild3.orgRoot.orgRootName}`,
orgChild3Name: orgChild3.orgChild3Name,
orgChild3ShortName: orgChild3.orgChild3ShortName,
orgChild3Code: orgChild3.orgChild3Code,
@ -66,7 +67,7 @@ export class OrgChild3Controller {
orgChild3PhoneIn: orgChild3.orgChild3PhoneIn,
orgChild3Fax: orgChild3.orgChild3Fax,
orgRevisionId: orgChild3.orgRevisionId,
orgCode: orgRoot.orgRootCode + orgChild3.orgChild3Code,
orgCode: orgChild3.orgRoot.orgRootCode + orgChild3.orgChild3Code,
};
return new HttpSuccess(getOrgChild3);
} catch (error) {