เพิ่ม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

@ -48,17 +48,18 @@ export class OrgChild4Controller extends Controller {
*/
@Get("{id}")
async GetChild4(@Path() id: string) {
const orgChild4 = await this.child4Repository.findOne({ where: { id } });
const orgChild4 = await this.child4Repository.findOne({
where: { id },
relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3"],
});
if (!orgChild4) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล โครงสร้างระดับ 4");
}
const orgRoot = await this.orgRootRepository.findOne({ where: { id: orgChild4.orgRootId } });
if (!orgRoot) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล โครงสร้างระดับ Root");
}
try {
const getOrgChild4 = {
orgChild4Id: orgChild4.id,
orgRootName: orgChild4.orgRoot.orgRootName,
orgName: `${orgChild4.orgChild4Name}/${orgChild4.orgChild3.orgChild3Name}/${orgChild4.orgChild2.orgChild2Name}/${orgChild4.orgChild1.orgChild1Name}/${orgChild4.orgRoot.orgRootName}`,
orgChild4Name: orgChild4.orgChild4Name,
orgChild4ShortName: orgChild4.orgChild4ShortName,
orgChild4Code: orgChild4.orgChild4Code,
@ -68,7 +69,7 @@ export class OrgChild4Controller extends Controller {
orgChild4PhoneIn: orgChild4.orgChild4PhoneIn,
orgChild4Fax: orgChild4.orgChild4Fax,
orgRevisionId: orgChild4.orgRevisionId,
orgCode: orgRoot.orgRootCode + orgChild4.orgChild4Code,
orgCode: orgChild4.orgRoot.orgRootCode + orgChild4.orgChild4Code,
};
return new HttpSuccess(getOrgChild4);
} catch (error) {