Skip to content

Commit

Permalink
dd
Browse files Browse the repository at this point in the history
  • Loading branch information
jihwooon committed Dec 18, 2023
1 parent 5f881f3 commit 1861726
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions server/src/item-images/application/item-image.creater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion server/src/item-images/application/item-image.updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}에 해당하는 이미지를 찾을 수 없습니다.`)
}

Expand Down

0 comments on commit 1861726

Please sign in to comment.