From cb92b360e87357d722f9f7e528afd865856424d1 Mon Sep 17 00:00:00 2001 From: sichoi42 <42.4.sichoi@gmail.com> Date: Sun, 6 Nov 2022 16:35:43 +0900 Subject: [PATCH] :adhesive_bandage: fix simple bug in lent and return #114 fix simple bug in lent and return #114 --- backend/src/v3/lent/lent.component.ts | 1 - backend/src/v3/return/return.service.ts | 27 ++++++++++--------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/backend/src/v3/lent/lent.component.ts b/backend/src/v3/lent/lent.component.ts index 95d35e8..bf7492e 100644 --- a/backend/src/v3/lent/lent.component.ts +++ b/backend/src/v3/lent/lent.component.ts @@ -50,7 +50,6 @@ export class LentTools { ); } await this.lentRepository.setExpireTimeAll(cabinet_id, expire_time); - runOnTransactionComplete((err) => err && this.logger.error(err)); } @Transactional({ diff --git a/backend/src/v3/return/return.service.ts b/backend/src/v3/return/return.service.ts index b1d3553..53c325f 100644 --- a/backend/src/v3/return/return.service.ts +++ b/backend/src/v3/return/return.service.ts @@ -72,35 +72,30 @@ export class ReturnService { async returnBundle(users: number[], cabinets: number[]): Promise { this.logger.debug(`Called ${ReturnService.name} ${this.returnBundle.name}`); + const user_failures = [] + const cabinets_failures = [] if (users) { - const failures = [] for await (const user_id of users) { await this.returnUserCabinet(user_id) .catch(() => { - failures.push(user_id); + user_failures.push(user_id); }) } - if (failures.length !== 0) { - throw new HttpException( - { "user_failures": failures }, - HttpStatus.BAD_REQUEST, - ); - } } if (cabinets) { - const failures = [] for await (const cabinet_id of cabinets) { await this.returnCabinet(cabinet_id) .catch(() => { - failures.push(cabinet_id); + cabinets_failures.push(cabinet_id); }) } - if (failures.length !== 0) { - throw new HttpException( - { "cabinet_failures": failures }, - HttpStatus.BAD_REQUEST, - ); - } + } + if (!(user_failures.length === 0 && cabinets_failures.length === 0)) { + throw new HttpException({ + "user_failures": user_failures, + "cabinet_failures": cabinets_failures, + }, HttpStatus.BAD_REQUEST, + ); } } }