แก้ฟิลด์ orgCode
This commit is contained in:
parent
5a7e5cfa0e
commit
e82b4f6a85
5 changed files with 31 additions and 9 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue