From 1861726c132fd5e2299a7348d142d8287ec12a6f Mon Sep 17 00:00:00 2001 From: jihwooon Date: Mon, 18 Dec 2023 14:15:59 +0900 Subject: [PATCH] dd --- .../item-images/application/item-image.creater.ts | 13 +++++++------ .../item-images/application/item-image.updater.ts | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/server/src/item-images/application/item-image.creater.ts b/server/src/item-images/application/item-image.creater.ts index 45f32da..8e81e9c 100644 --- a/server/src/item-images/application/item-image.creater.ts +++ b/server/src/item-images/application/item-image.creater.ts @@ -13,15 +13,16 @@ export class ItemImageCreater { ) {} async saveItemImages(itemId: number, @UploadedFiles() files: Express.Multer.File[]) { - if (Array.isArray(files) && files.length === 0) { + if (!files || files.length === 0) { throw new FileIsNotEmpty('파일은 필수 입력 값입니다') } - files.map((file, i) => { - const isRepresentImage: boolean = i === 0 - - this.saveItemImage(itemId, { ...file }, isRepresentImage) - }) + await Promise.all( + files.map((file, i) => { + const isRepresentImage: boolean = i === 0 + this.saveItemImage(itemId, { ...file }, isRepresentImage) + }), + ) } async saveItemImage(itemId: number, @UploadedFiles() file: Express.Multer.File, isRepresentImage) { diff --git a/server/src/item-images/application/item-image.updater.ts b/server/src/item-images/application/item-image.updater.ts index db3147f..d82db4c 100644 --- a/server/src/item-images/application/item-image.updater.ts +++ b/server/src/item-images/application/item-image.updater.ts @@ -13,7 +13,7 @@ export class ItemImageUpdater { const { id } = items const itemImages = await this.itemImageRepository.findByItemOrderByItemImageIdAsc(id) - if (Array.isArray(itemImages) && itemImages.length === 0) { + if (!itemImages || itemImages.length === 0) { throw new ItemImageNotFoundException(`${id}에 해당하는 이미지를 찾을 수 없습니다.`) }