File tree Expand file tree Collapse file tree 2 files changed +23
-8
lines changed
Expand file tree Collapse file tree 2 files changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -53,18 +53,23 @@ export const ChatroomService = {
5353
5454 const chatrooms = await ChatroomRepository . findChatroomsByUser ( dto . userId ) ;
5555
56- // thumbnail 한 번에 조회
57- const commissionIds = chatrooms . map ( r => r . commission . id ) ;
58- const images = await CommissionRepository . findImagesByCommissionId ( commissionIds ) ;
59- const thumbnailMap = Object . fromEntries ( images . map ( img => [ img . targetId . toString ( ) , img . imageUrl ] ) ) ;
56+ // 1. thumbnail 한 번에 조회 (BigInt 변환)
57+ const commissionIds = chatrooms . map ( r => BigInt ( r . commission . id ) ) ;
58+ const images = await CommissionRepository . findImagesByCommissionIds ( commissionIds ) ;
59+ const thumbnailMap = Object . fromEntries (
60+ images . map ( img => [ img . targetId . toString ( ) , img . imageUrl ] )
61+ ) ;
6062
61- // DTO 생성
63+ // 2. DTO 생성
6264 const result = [ ] ;
6365 for ( const room of chatrooms ) {
64- room . commission . thumbnail = thumbnailMap [ room . commission . id . toString ( ) ] || null ;
66+ room . commission . thumbnail = thumbnailMap [ BigInt ( room . commission . id ) . toString ( ) ] || null ;
6567
66- // 방마다 unreadCount 조회
67- const unreadCount = await ChatRepository . countUnreadMessages ( room . id , dto . accountId ) ;
68+ // 방마다 unreadCount 조회 (BigInt 변환)
69+ const unreadCount = await ChatRepository . countUnreadMessages (
70+ BigInt ( room . id ) ,
71+ BigInt ( dto . accountId )
72+ ) ;
6873
6974 result . push ( new ChatroomListResponseDto ( room , unreadCount ) ) ;
7075 }
Original file line number Diff line number Diff line change @@ -68,6 +68,16 @@ export const CommissionRepository = {
6868 } ) ;
6969 } ,
7070
71+ async findImagesByCommissionIds ( commissionIds ) {
72+ return await prisma . image . findMany ( {
73+ where : {
74+ target : 'commissions' ,
75+ targetId : { in : commissionIds } , // 배열 처리
76+ } ,
77+ orderBy : { orderIndex : 'asc' } ,
78+ } ) ;
79+ } ,
80+
7181 /**
7282 * 커미션 ID로 신청폼 조회 (작가 정보 포함)
7383 */
You can’t perform that action at this time.
0 commit comments