แก้ error สร้าง node
This commit is contained in:
parent
634c82eb5c
commit
60b25c6620
6 changed files with 39 additions and 47 deletions
|
|
@ -134,12 +134,12 @@ export class OrgChild4Controller extends Controller {
|
|||
if (!validOrgChild4Ranks.includes(requestBody.orgChild4Rank.toUpperCase())) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. orgChild4Rank");
|
||||
}
|
||||
const order:any = await this.child4Repository.findOne({
|
||||
const order: any = await this.child4Repository.findOne({
|
||||
where: {
|
||||
orgChild3Id: requestBody.orgChild3Id
|
||||
orgChild3Id: requestBody.orgChild3Id,
|
||||
},
|
||||
order: { orgChild4Order: "DESC" }
|
||||
})
|
||||
order: { orgChild4Order: "DESC" },
|
||||
});
|
||||
try {
|
||||
const child4 = Object.assign(new OrgChild4(), requestBody) as OrgChild4;
|
||||
child4.orgChild4Name = requestBody.orgChild4Name;
|
||||
|
|
@ -152,7 +152,8 @@ export class OrgChild4Controller extends Controller {
|
|||
child4.orgChild2Id = String(child3?.orgChild2Id);
|
||||
child4.orgRevisionId = String(child3?.orgRevisionId);
|
||||
child4.orgChild3Id = String(child3?.id);
|
||||
child4.orgChild4Order = order.orgChild4Order == null ? 1 : order.orgChild4Order+1;
|
||||
child4.orgChild4Order =
|
||||
order == null || order.orgChild4Order == null ? 1 : order.orgChild4Order + 1;
|
||||
await this.child4Repository.save(child4);
|
||||
|
||||
return new HttpSuccess();
|
||||
|
|
@ -271,7 +272,7 @@ export class OrgChild4Controller extends Controller {
|
|||
}
|
||||
try {
|
||||
const posMasters = await this.posMasterRepository.find({
|
||||
where: { orgChild4Id: id}
|
||||
where: { orgChild4Id: id },
|
||||
});
|
||||
const positions = await this.positionRepository.find({
|
||||
where: [{ posMasterId: In(posMasters.map((x) => x.id)) }],
|
||||
|
|
@ -279,7 +280,7 @@ export class OrgChild4Controller extends Controller {
|
|||
|
||||
await this.positionRepository.remove(positions);
|
||||
await this.posMasterRepository.remove(posMasters);
|
||||
await this.child4Repository.delete( id );
|
||||
await this.child4Repository.delete(id);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue