File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import multer from 'multer';
22import path from 'path' ;
33import fs from 'fs' ;
44import { CommissionRepository } from "../repository/commission.repository.js" ;
5+ import { RequestRepository } from "../../request/repository/request.repository.js" ;
56import {
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 ,
Original file line number Diff line number Diff 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} ;
You can’t perform that action at this time.
0 commit comments