แก้apiแสดงข้อมูลtree
This commit is contained in:
parent
49c468f53d
commit
9166faf102
6 changed files with 486 additions and 144 deletions
|
|
@ -36,7 +36,7 @@ export class OrgChild3Controller {
|
|||
private child3Repository = AppDataSource.getRepository(OrgChild3);
|
||||
private child4Repository = AppDataSource.getRepository(OrgChild4);
|
||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||
|
||||
|
||||
/**
|
||||
* API รายละเอียดโครงสร้างระดับ 3
|
||||
*
|
||||
|
|
@ -56,18 +56,18 @@ export class OrgChild3Controller {
|
|||
}
|
||||
try {
|
||||
const getOrgChild3 = {
|
||||
"orgChild3Id" : orgChild3.id,
|
||||
"orgChild3Name" : orgChild3.orgChild3Name,
|
||||
"orgChild3ShortName" : orgChild3.orgChild3ShortName,
|
||||
"orgChild3Code" : orgChild3.orgChild3Code,
|
||||
"orgChild3Rank" : orgChild3.orgChild3Rank,
|
||||
"orgChild3Order" : orgChild3.orgChild3Order,
|
||||
"orgChild3PhoneEx" : orgChild3.orgChild3PhoneEx,
|
||||
"orgChild3PhoneIn" : orgChild3.orgChild3PhoneIn,
|
||||
"orgChild3Fax" : orgChild3.orgChild3Fax,
|
||||
"orgRevisionId" : orgChild3.orgRevisionId,
|
||||
"orgCode" : orgRoot.orgRootCode + orgChild3.orgChild3Code
|
||||
}
|
||||
orgChild3Id: orgChild3.id,
|
||||
orgChild3Name: orgChild3.orgChild3Name,
|
||||
orgChild3ShortName: orgChild3.orgChild3ShortName,
|
||||
orgChild3Code: orgChild3.orgChild3Code,
|
||||
orgChild3Rank: orgChild3.orgChild3Rank,
|
||||
orgChild3Order: orgChild3.orgChild3Order,
|
||||
orgChild3PhoneEx: orgChild3.orgChild3PhoneEx,
|
||||
orgChild3PhoneIn: orgChild3.orgChild3PhoneIn,
|
||||
orgChild3Fax: orgChild3.orgChild3Fax,
|
||||
orgRevisionId: orgChild3.orgRevisionId,
|
||||
orgCode: orgRoot.orgRootCode + orgChild3.orgChild3Code,
|
||||
};
|
||||
return new HttpSuccess(getOrgChild3);
|
||||
} catch (error) {
|
||||
return error;
|
||||
|
|
@ -98,8 +98,14 @@ export class OrgChild3Controller {
|
|||
if (!revisionIdExits) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. RevisionId");
|
||||
}
|
||||
if(revisionIdExits.orgRevisionIsDraft != true && revisionIdExits.orgRevisionIsCurrent != false){
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. orgRevisionIsDraft:true, orgRevisionIsCurrent:false");
|
||||
if (
|
||||
revisionIdExits.orgRevisionIsDraft != true &&
|
||||
revisionIdExits.orgRevisionIsCurrent != false
|
||||
) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"not found. orgRevisionIsDraft:true, orgRevisionIsCurrent:false",
|
||||
);
|
||||
}
|
||||
|
||||
const validOrgChild3Ranks = ["OFFICE", "DIVISION", "SECTION"];
|
||||
|
|
@ -150,8 +156,14 @@ export class OrgChild3Controller {
|
|||
if (!revisionIdExits) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. RevisionId");
|
||||
}
|
||||
if(revisionIdExits.orgRevisionIsDraft != true && revisionIdExits.orgRevisionIsCurrent != false){
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. orgRevisionIsDraft:true, orgRevisionIsCurrent:false");
|
||||
if (
|
||||
revisionIdExits.orgRevisionIsDraft != true &&
|
||||
revisionIdExits.orgRevisionIsCurrent != false
|
||||
) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"not found. orgRevisionIsDraft:true, orgRevisionIsCurrent:false",
|
||||
);
|
||||
}
|
||||
|
||||
const validOrgChild3Ranks = ["OFFICE", "DIVISION", "SECTION"];
|
||||
|
|
@ -195,15 +207,21 @@ export class OrgChild3Controller {
|
|||
if (!child3) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
|
||||
}
|
||||
|
||||
|
||||
const revisionIdExits = await this.orgRevisionRepository.findOne({
|
||||
where: { id: child3.orgRevisionId },
|
||||
});
|
||||
if (!revisionIdExits) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. RevisionId");
|
||||
}
|
||||
if(revisionIdExits.orgRevisionIsDraft != true && revisionIdExits.orgRevisionIsCurrent != false){
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. orgRevisionIsDraft:true, orgRevisionIsCurrent:false");
|
||||
if (
|
||||
revisionIdExits.orgRevisionIsDraft != true &&
|
||||
revisionIdExits.orgRevisionIsCurrent != false
|
||||
) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"not found. orgRevisionIsDraft:true, orgRevisionIsCurrent:false",
|
||||
);
|
||||
}
|
||||
|
||||
const exitsChild4 = await this.child4Repository.findOne({ where: { orgChild3Id: id } });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue