แก้ฟิลด์ orgCode
This commit is contained in:
parent
5a7e5cfa0e
commit
e82b4f6a85
5 changed files with 31 additions and 9 deletions
|
|
@ -50,7 +50,11 @@ export class OrgChild1Controller {
|
|||
try {
|
||||
const orgChild1 = await this.child1Repository.findOne({ where: { id } });
|
||||
if (!orgChild1) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
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");
|
||||
}
|
||||
const getOrgChild1 = {
|
||||
"orgChild1Id" : orgChild1.id,
|
||||
|
|
@ -62,7 +66,7 @@ export class OrgChild1Controller {
|
|||
"orgChild1PhoneIn" : orgChild1.orgChild1PhoneIn,
|
||||
"orgChild1Fax" : orgChild1.orgChild1Fax,
|
||||
"orgRevisionId" : orgChild1.orgRevisionId,
|
||||
"orgCode" : orgChild1.orgChild1Code+"00"
|
||||
"orgCode" : orgRoot.orgRootCode + orgChild1.orgChild1Code
|
||||
}
|
||||
return new HttpSuccess(getOrgChild1);
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import HttpStatusCode from "../interfaces/http-status";
|
|||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
import { OrgRoot } from "../entities/OrgRoot";
|
||||
import { CreateOrgChild2, OrgChild2, UpdateOrgChild2 } from "../entities/OrgChild2";
|
||||
import { OrgChild1 } from "../entities/OrgChild1";
|
||||
import { OrgChild3 } from "../entities/OrgChild3";
|
||||
|
|
@ -32,6 +33,7 @@ import { OrgChild3 } from "../entities/OrgChild3";
|
|||
)
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class OrgChild2Controller extends Controller {
|
||||
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
|
||||
private child1Repository = AppDataSource.getRepository(OrgChild1);
|
||||
private child2Repository = AppDataSource.getRepository(OrgChild2);
|
||||
private child3Repository = AppDataSource.getRepository(OrgChild3);
|
||||
|
|
@ -49,7 +51,11 @@ export class OrgChild2Controller extends Controller {
|
|||
try {
|
||||
const orgChild2 = await this.child2Repository.findOne({ where: { id } });
|
||||
if (!orgChild2) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล โครงสร้างระดับ 2");
|
||||
}
|
||||
const orgRoot = await this.orgRootRepository.findOne({ where: { id: orgChild2.orgRootId } });
|
||||
if (!orgRoot) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล โครงสร้างระดับ Root");
|
||||
}
|
||||
const getOrgChild2 = {
|
||||
"orgChild2Id" : orgChild2.id,
|
||||
|
|
@ -61,7 +67,7 @@ export class OrgChild2Controller extends Controller {
|
|||
"orgChild2PhoneIn" : orgChild2.orgChild2PhoneIn,
|
||||
"orgChild2Fax" : orgChild2.orgChild2Fax,
|
||||
"orgRevisionId" : orgChild2.orgRevisionId,
|
||||
"orgCode" : orgChild2.orgChild2Code+"00"
|
||||
"orgCode" : orgRoot.orgRootCode + orgChild2.orgChild2Code
|
||||
}
|
||||
return new HttpSuccess(getOrgChild2);
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { AppDataSource } from "../database/data-source";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
import { OrgRoot } from "../entities/OrgRoot";
|
||||
import { OrgChild2 } from "../entities/OrgChild2";
|
||||
import { OrgChild3, CreateOrgChild3, UpdateOrgChild3 } from "../entities/OrgChild3";
|
||||
import { OrgChild4 } from "../entities/OrgChild4";
|
||||
|
|
@ -30,6 +31,7 @@ import HttpError from "../interfaces/http-error";
|
|||
)
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class OrgChild3Controller {
|
||||
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
|
||||
private child2Repository = AppDataSource.getRepository(OrgChild2);
|
||||
private child3Repository = AppDataSource.getRepository(OrgChild3);
|
||||
private child4Repository = AppDataSource.getRepository(OrgChild4);
|
||||
|
|
@ -47,7 +49,11 @@ export class OrgChild3Controller {
|
|||
try {
|
||||
const orgChild3 = await this.child3Repository.findOne({ where: { id } });
|
||||
if (!orgChild3) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
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");
|
||||
}
|
||||
const getOrgChild3 = {
|
||||
"orgChild3Id" : orgChild3.id,
|
||||
|
|
@ -59,7 +65,7 @@ export class OrgChild3Controller {
|
|||
"orgChild3PhoneIn" : orgChild3.orgChild3PhoneIn,
|
||||
"orgChild3Fax" : orgChild3.orgChild3Fax,
|
||||
"orgRevisionId" : orgChild3.orgRevisionId,
|
||||
"orgCode" : orgChild3.orgChild3Code+"00"
|
||||
"orgCode" : orgRoot.orgRootCode + orgChild3.orgChild3Code
|
||||
}
|
||||
return new HttpSuccess(getOrgChild3);
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import HttpStatusCode from "../interfaces/http-status";
|
|||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
import { OrgRoot } from "../entities/OrgRoot";
|
||||
import { CreateOrgChild4, OrgChild4, UpdateOrgChild4 } from "../entities/OrgChild4";
|
||||
import { OrgChild1 } from "../entities/OrgChild1";
|
||||
import { OrgChild3 } from "../entities/OrgChild3";
|
||||
|
|
@ -33,6 +34,7 @@ import { OrgChild3 } from "../entities/OrgChild3";
|
|||
)
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class OrgChild4Controller extends Controller {
|
||||
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
|
||||
private child3Repository = AppDataSource.getRepository(OrgChild3);
|
||||
private child4Repository = AppDataSource.getRepository(OrgChild4);
|
||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||
|
|
@ -49,8 +51,12 @@ export class OrgChild4Controller extends Controller {
|
|||
try {
|
||||
const orgChild4 = await this.child4Repository.findOne({ where: { id } });
|
||||
if (!orgChild4) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
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");
|
||||
}
|
||||
const getOrgChild4 = {
|
||||
"orgChild4Id" : orgChild4.id,
|
||||
"orgChild4Name" : orgChild4.orgChild4Name,
|
||||
|
|
@ -61,7 +67,7 @@ export class OrgChild4Controller extends Controller {
|
|||
"orgChild4PhoneIn" : orgChild4.orgChild4PhoneIn,
|
||||
"orgChild4Fax" : orgChild4.orgChild4Fax,
|
||||
"orgRevisionId" : orgChild4.orgRevisionId,
|
||||
"orgCode" : orgChild4.orgChild4Code+"00"
|
||||
"orgCode" : orgRoot.orgRootCode + orgChild4.orgChild4Code
|
||||
}
|
||||
return new HttpSuccess(getOrgChild4);
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ export class OrgRootController extends Controller {
|
|||
try {
|
||||
const orgRoot = await this.orgRootRepository.findOne({ where: { id } });
|
||||
if (!orgRoot) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล โครงสร้างระดับ Root");
|
||||
}
|
||||
const getOrgRoot = {
|
||||
"orgRootId" : orgRoot.id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue