Skip to content

Commit 525cedd

Browse files
committed
fix: 참고 이미지 저장 오류 수정
1 parent b9e8b34 commit 525cedd

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/commission/service/commission.service.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import multer from 'multer';
22
import path from 'path';
33
import fs from 'fs';
44
import { CommissionRepository } from "../repository/commission.repository.js";
5+
import { RequestRepository } from "../../request/repository/request.repository.js";
56
import {
67
CommissionNotFoundError,
78
FileSizeExceededError,
@@ -286,6 +287,21 @@ export const CommissionService = {
286287
waitlist: waitlist
287288
});
288289

290+
// 참고 이미지들을 Image 테이블에 저장
291+
const fileFieldId = (customFields.length + 2).toString();
292+
const imageUrls = formAnswer[fileFieldId] || [];
293+
294+
if (imageUrls.length > 0) {
295+
for (let i = 0; i < imageUrls.length; i++) {
296+
await RequestRepository.createRequestImage({
297+
target: 'request',
298+
targetId: newRequest.id,
299+
imageUrl: imageUrls[i],
300+
orderIndex: i
301+
});
302+
}
303+
}
304+
289305
// 응답 데이터 구성
290306
return {
291307
requestId: newRequest.id,

src/request/repository/request.repository.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,5 +228,19 @@ async findImagesByRequestId(requestId) {
228228
},
229229
orderBy: { orderIndex: 'asc' }
230230
});
231+
},
232+
233+
/**
234+
* Request 이미지 생성
235+
*/
236+
async createRequestImage(imageData) {
237+
return await prisma.image.create({
238+
data: {
239+
target: imageData.target,
240+
targetId: imageData.targetId,
241+
imageUrl: imageData.imageUrl,
242+
orderIndex: imageData.orderIndex
243+
}
244+
});
231245
}
232246
};

0 commit comments

Comments
 (0)