แก้ error สร้าง node
This commit is contained in:
parent
634c82eb5c
commit
60b25c6620
6 changed files with 39 additions and 47 deletions
|
|
@ -118,12 +118,12 @@ export class OrgChild3Controller {
|
|||
if (!validOrgChild3Ranks.includes(requestBody.orgChild3Rank.toUpperCase())) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. orgChild3Rank");
|
||||
}
|
||||
const order:any = await this.child3Repository.findOne({
|
||||
const order: any = await this.child3Repository.findOne({
|
||||
where: {
|
||||
orgChild2Id: requestBody.orgChild2Id
|
||||
orgChild2Id: requestBody.orgChild2Id,
|
||||
},
|
||||
order: { orgChild3Order: "DESC" }
|
||||
})
|
||||
order: { orgChild3Order: "DESC" },
|
||||
});
|
||||
try {
|
||||
const child3 = Object.assign(new OrgChild3(), requestBody) as OrgChild3;
|
||||
child3.orgChild3Name = requestBody.orgChild3Name;
|
||||
|
|
@ -135,7 +135,8 @@ export class OrgChild3Controller {
|
|||
child3.orgChild1Id = String(child2?.orgChild1Id);
|
||||
child3.orgRevisionId = String(child2?.orgRevisionId);
|
||||
child3.orgChild2Id = String(child2?.id);
|
||||
child3.orgChild3Order = order.orgChild3Order == null ? 1 : order.orgChild3Order+1;
|
||||
child3.orgChild3Order =
|
||||
order == null || order.orgChild3Order == null ? 1 : order.orgChild3Order + 1;
|
||||
await this.child3Repository.save(child3);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
|
|
@ -246,7 +247,7 @@ export class OrgChild3Controller {
|
|||
// }
|
||||
try {
|
||||
const posMasters = await this.posMasterRepository.find({
|
||||
where: { orgChild3Id: id}
|
||||
where: { orgChild3Id: id },
|
||||
});
|
||||
const positions = await this.positionRepository.find({
|
||||
where: [{ posMasterId: In(posMasters.map((x) => x.id)) }],
|
||||
|
|
@ -255,7 +256,7 @@ export class OrgChild3Controller {
|
|||
await this.positionRepository.remove(positions);
|
||||
await this.posMasterRepository.remove(posMasters);
|
||||
await this.child4Repository.delete({ orgChild3Id: id });
|
||||
await this.child3Repository.delete( id );
|
||||
await this.child3Repository.delete(id);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue