From 481b5c544ecbd38c985143ecc28b0e7fbac934d5 Mon Sep 17 00:00:00 2001 From: Arin0303 Date: Fri, 23 Jan 2026 15:46:27 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20repository-=20create=20chat=20parti?= =?UTF-8?q?cipant=ED=95=A8=EC=88=98=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat/repositories/chat.repository.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/chat/repositories/chat.repository.ts b/src/chat/repositories/chat.repository.ts index 3edc147..1d0bb77 100644 --- a/src/chat/repositories/chat.repository.ts +++ b/src/chat/repositories/chat.repository.ts @@ -22,6 +22,24 @@ export class ChatRepository { }); } + async createChatParticipant(roomId: number, userId1: number, userId2: number) { + return Promise.all([ + prisma.chatParticipant.create({ + data: { + room_id: roomId, + user_id: userId1, + }, + }), + prisma.chatParticipant.create({ + data: { + room_id: roomId, + user_id: userId2, + }, + }), + ]); + } + + async findRoomDetailWithParticipant(roomId: number) { return prisma.chatRoom.findUnique({ where: { room_id: roomId }, From 81c5549e9f39975b5a9973d8cb919151e9115590 Mon Sep 17 00:00:00 2001 From: Arin0303 Date: Fri, 23 Jan 2026 23:10:53 +0900 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=ED=95=98=EB=82=98=EC=9D=98=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=EB=A1=9C=20=EC=B0=B8=EC=97=AC=EC=9E=90=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=EA=B9=8C=EC=A7=80=20=ED=95=A9=EC=B9=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat/repositories/chat.repository.ts | 25 +++++++----------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/chat/repositories/chat.repository.ts b/src/chat/repositories/chat.repository.ts index 1d0bb77..68bd053 100644 --- a/src/chat/repositories/chat.repository.ts +++ b/src/chat/repositories/chat.repository.ts @@ -18,28 +18,17 @@ export class ChatRepository { user_id1: userId1, user_id2: userId2, last_message_id: null, + // 참여자 생성 + participants: { + create: [ + { user_id: userId1}, + { user_id: userId2}, + ], + } }, }); } - async createChatParticipant(roomId: number, userId1: number, userId2: number) { - return Promise.all([ - prisma.chatParticipant.create({ - data: { - room_id: roomId, - user_id: userId1, - }, - }), - prisma.chatParticipant.create({ - data: { - room_id: roomId, - user_id: userId2, - }, - }), - ]); - } - - async findRoomDetailWithParticipant(roomId: number) { return prisma.chatRoom.findUnique({ where: { room_id: roomId }, From e9d73b63f3f769fb2698d5f35af313664649bddb Mon Sep 17 00:00:00 2001 From: Arin0303 Date: Fri, 23 Jan 2026 23:36:23 +0900 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20last=5Fmessage=5Fid=20=EC=97=86?= =?UTF-8?q?=EC=9D=84=20=EC=8B=9C=20=EC=B1=84=ED=8C=85=EB=B0=A9=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20=EB=A6=AC=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=A0=9C=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat/repositories/chat.repository.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/chat/repositories/chat.repository.ts b/src/chat/repositories/chat.repository.ts index 68bd053..5d1966e 100644 --- a/src/chat/repositories/chat.repository.ts +++ b/src/chat/repositories/chat.repository.ts @@ -118,6 +118,8 @@ export class ChatRepository { const where: Prisma.ChatParticipantWhereInput = { user_id: userId, left_at: null, // 나가지 않은 방 + chatRoom: { + is: { last_message_id: { not: null } } }, // 메시지가 있는 방 }; if (filter === "pinned") { @@ -130,16 +132,17 @@ export class ChatRepository { if (search && search.trim().length > 0) { where.chatRoom = { - participants: { - some: { - user_id: { not: userId }, - user: { - nickname: { - contains: search.trim(), + is: { + ...(where.chatRoom as any)?.is, + participants: { + some: { + user_id: { not: userId }, + user: { + nickname: {contains: search.trim()}, }, }, }, - }, + } }; } From 77e03ad0f308f0cf609daca189f48fe06eb09a8d Mon Sep 17 00:00:00 2001 From: Arin0303 Date: Fri, 23 Jan 2026 23:46:58 +0900 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20swagger=20=EB=AC=B8=EC=84=9C?= =?UTF-8?q?=EC=97=90=20br=20=ED=83=9C=EA=B7=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat/routes/chat.route.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/chat/routes/chat.route.ts b/src/chat/routes/chat.route.ts index 81f634c..5cfe2ad 100644 --- a/src/chat/routes/chat.route.ts +++ b/src/chat/routes/chat.route.ts @@ -68,7 +68,7 @@ router.post("/rooms", authenticateJwt, createOrGetChatRoom); * get: * summary: 채팅방 상세 조회 * description: > - * 채팅방 상세 정보(상대 정보/차단 상태/메시지 목록/페이지 정보)를 조회합니다. + * 채팅방 상세 정보(상대 정보/차단 상태/메시지 목록/페이지 정보)를 조회합니다.
* 메시지는 오래된 순(ASC)으로 반환되며, cursor 기반으로 과거 메시지를 추가로 불러올 수 있습니다. * tags: [Chat] * security: @@ -227,7 +227,8 @@ router.get("/rooms/:roomId", authenticateJwt, getChatRoomDetail); * get: * summary: 채팅방 목록 조회 * description: > - * 내 채팅방 목록을 조회합니다. + * 내 채팅방 목록을 조회합니다.
+ * 메세지가 존재하지 않으면 해당 채팅방은 목록에서 제외됩니다.
* filter(전체/안읽음/고정), search(상대 닉네임 검색), cursor 기반 페이징을 지원합니다. * tags: [Chat] * security: