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

@ -47,17 +47,18 @@ export class OrgChild1Controller {
*/
@Get("{id}")
async GetChild1(@Path() id: string) {
const orgChild1 = await this.child1Repository.findOne({ where: { id } });
const orgChild1 = await this.child1Repository.findOne({
where: { id },
relations: ["orgRoot"],
});
if (!orgChild1) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล โครงสร้างระดับ 1");
}
const orgRoot = await this.orgRootRepository.findOne({ where: { id: orgChild1.orgRootId } });
if (!orgRoot) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล โครงสร้างระดับ Root");
}
try {
const getOrgChild1 = {
orgChild1Id: orgChild1.id,
orgRootName: orgChild1.orgRoot.orgRootName,
orgName: `${orgChild1.orgChild1Name}/${orgChild1.orgRoot.orgRootName}`,
orgChild1Name: orgChild1.orgChild1Name,
orgChild1ShortName: orgChild1.orgChild1ShortName,
orgChild1Code: orgChild1.orgChild1Code,
@ -67,7 +68,7 @@ export class OrgChild1Controller {
orgChild1PhoneIn: orgChild1.orgChild1PhoneIn,
orgChild1Fax: orgChild1.orgChild1Fax,
orgRevisionId: orgChild1.orgRevisionId,
orgCode: orgRoot.orgRootCode + orgChild1.orgChild1Code,
orgCode: orgChild1.orgRoot.orgRootCode + orgChild1.orgChild1Code,
};
return new HttpSuccess(getOrgChild1);
} catch (error) {