แก้ error สร้าง node
This commit is contained in:
parent
634c82eb5c
commit
60b25c6620
6 changed files with 39 additions and 47 deletions
|
|
@ -130,12 +130,12 @@ export class OrgChild1Controller {
|
|||
if (chkCode != null) {
|
||||
throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "รหัสหน่วยงานนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
const order:any = await this.child1Repository.findOne({
|
||||
const order: any = await this.child1Repository.findOne({
|
||||
where: {
|
||||
orgRootId: requestBody.orgRootId
|
||||
orgRootId: requestBody.orgRootId,
|
||||
},
|
||||
order: { orgChild1Order: "DESC" }
|
||||
})
|
||||
order: { orgChild1Order: "DESC" },
|
||||
});
|
||||
try {
|
||||
const child1 = Object.assign(new OrgChild1(), requestBody) as OrgChild1;
|
||||
child1.orgChild1Name = requestBody.orgChild1Name;
|
||||
|
|
@ -145,7 +145,8 @@ export class OrgChild1Controller {
|
|||
child1.lastUpdateFullName = request.user.name;
|
||||
child1.orgRevisionId = String(rootIdExits?.orgRevisionId);
|
||||
child1.orgRootId = String(rootIdExits?.id);
|
||||
child1.orgChild1Order = order.orgChild1Order == null ? 1 : order.orgChild1Order+1;
|
||||
child1.orgChild1Order =
|
||||
order == null || order.orgChild1Order == null ? 1 : order.orgChild1Order + 1;
|
||||
await this.child1Repository.save(child1);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
|
|
@ -262,7 +263,7 @@ export class OrgChild1Controller {
|
|||
// }
|
||||
try {
|
||||
const posMasters = await this.posMasterRepository.find({
|
||||
where: { orgChild1Id: id}
|
||||
where: { orgChild1Id: id },
|
||||
});
|
||||
const positions = await this.positionRepository.find({
|
||||
where: [{ posMasterId: In(posMasters.map((x) => x.id)) }],
|
||||
|
|
@ -273,7 +274,7 @@ export class OrgChild1Controller {
|
|||
await this.child4Repository.delete({ orgChild1Id: id });
|
||||
await this.child3Repository.delete({ orgChild1Id: id });
|
||||
await this.child2Repository.delete({ orgChild1Id: id });
|
||||
await this.child1Repository.delete({id});
|
||||
await this.child1Repository.delete({ id });
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue