ปรับ validate orgRevision (child1-4)
This commit is contained in:
parent
4a6fb0aa28
commit
7d6d214b98
4 changed files with 48 additions and 12 deletions
|
|
@ -110,11 +110,14 @@ export class OrgChild2Controller extends Controller {
|
|||
}
|
||||
|
||||
const revisionIdExits = await this.orgRevisionRepository.findOne({
|
||||
where: { id: child1.orgRevisionId, orgRevisionIsDraft: true, orgRevisionIsCurrent: false },
|
||||
where: { id: child1.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");
|
||||
}
|
||||
|
||||
const validOrgChild2Ranks = ["OFFICE", "DIVISION", "SECTION"];
|
||||
if (!validOrgChild2Ranks.includes(requestBody.orgChild2Rank.toUpperCase())) {
|
||||
|
|
@ -173,11 +176,14 @@ export class OrgChild2Controller extends Controller {
|
|||
}
|
||||
|
||||
const revisionIdExits = await this.orgRevisionRepository.findOne({
|
||||
where: { id: child1IdExits.orgRevisionId, orgRevisionIsDraft: true, orgRevisionIsCurrent: false },
|
||||
where: { id: child1IdExits.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");
|
||||
}
|
||||
|
||||
const validOrgChild2Ranks = ["OFFICE", "DIVISION", "SECTION"];
|
||||
if (
|
||||
|
|
@ -222,11 +228,14 @@ export class OrgChild2Controller extends Controller {
|
|||
}
|
||||
|
||||
const revisionIdExits = await this.orgRevisionRepository.findOne({
|
||||
where: { id: child2.orgRevisionId, orgRevisionIsDraft: true, orgRevisionIsCurrent: false },
|
||||
where: { id: child2.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");
|
||||
}
|
||||
|
||||
const exitsChild3 = await this.child3Repository.findOne({ where: { orgChild2Id: id } });
|
||||
if (exitsChild3) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue