44import cmf .commitField .domain .chat .chatRoom .dto .ChatRoomDto ;
55import cmf .commitField .domain .chat .chatRoom .service .ChatRoomService ;
66import cmf .commitField .domain .user .entity .CustomOAuth2User ;
7+ import cmf .commitField .global .error .ErrorCode ;
78import cmf .commitField .global .globalDto .GlobalResponse ;
89import cmf .commitField .global .security .LoginCheck ;
910import jakarta .validation .Valid ;
@@ -32,9 +33,9 @@ public GlobalResponse<Object> createRoom(
3233 CustomOAuth2User principal = (CustomOAuth2User ) authentication .getPrincipal ();
3334 Long userId = principal .getId (); // getId()를 통해 userId를 추출
3435 chatRoomService .createRoom (chatRoomRequest , userId ); // userId를 전달
35- return GlobalResponse .success ();
36+ return GlobalResponse .success ("채팅방을 생성하였습니다." );
3637 } else {
37- throw new IllegalArgumentException ("User not logged in ." );
38+ throw new IllegalArgumentException ("로그인 후에 이용해 주세요 ." );
3839 }
3940 }
4041
@@ -47,9 +48,9 @@ public GlobalResponse<Object> joinRoom(@PathVariable Long roomId) {
4748 CustomOAuth2User principal = (CustomOAuth2User ) authentication .getPrincipal ();
4849 Long userId = principal .getId (); // getId()를 통해 userId를 추출
4950 chatRoomService .joinRoom (roomId , userId ); // userId를 전달
50- return GlobalResponse .success ();
51+ return GlobalResponse .success ("해당 채팅방에 입장하셨습니다" );
5152 } else {
52- throw new IllegalArgumentException ("User not logged in ." );
53+ throw new IllegalArgumentException ("로그인 후에 이용해 주세요 ." );
5354 }
5455 }
5556
@@ -58,7 +59,13 @@ public GlobalResponse<Object> joinRoom(@PathVariable Long roomId) {
5859 @ LoginCheck
5960 public GlobalResponse <Object > roomList (Pageable pageable ) {
6061 List <ChatRoomDto > roomList = chatRoomService .getRoomList (pageable );
61- return GlobalResponse .success (roomList );
62+
63+ // 방 리스트가 비어 있으면 notFound 응답 반환
64+ if (roomList .isEmpty ()) {
65+ return GlobalResponse .error (ErrorCode .NO_ROOM_FOUND );
66+ }
67+
68+ return GlobalResponse .success ("전체 목록 조회에 성공하였습니다." ,roomList );
6269 }
6370
6471 // 사용자(자신)가 생성한 방 리스트 조회
@@ -72,9 +79,15 @@ public GlobalResponse<Object> getByUserRoomList(Pageable pageable) {
7279 Long userId = principal .getId (); // getId()를 통해 userId를 추출
7380
7481 List <ChatRoomDto > userByRoomList = chatRoomService .getUserByRoomList (userId , pageable );
75- return GlobalResponse .success (userByRoomList );
82+
83+ // 방 리스트가 비어 있으면 notFound 응답 반환
84+ if (userByRoomList .isEmpty ()) {
85+ return GlobalResponse .error (ErrorCode .USER_CREATED_ROOM_NOT_FOUND );
86+ }
87+
88+ return GlobalResponse .success ("사용자가 생성한 방 조회 성공." ,userByRoomList );
7689 } else {
77- throw new IllegalArgumentException ("User not logged in ." );
90+ throw new IllegalArgumentException ("로그인 후에 이용해 주세요 ." );
7891 }
7992 }
8093
@@ -88,9 +101,15 @@ public GlobalResponse<Object> getByUserRoomPartList(Pageable pageable) {
88101 CustomOAuth2User principal = (CustomOAuth2User ) authentication .getPrincipal ();
89102 Long userId = principal .getId (); // getId()를 통해 userId를 추출
90103 List <ChatRoomDto > userByRoomPartList = chatRoomService .getUserByRoomPartList (userId , pageable );
91- return GlobalResponse .success (userByRoomPartList );
104+
105+ // 만약 방 리스트가 없다면 notFound 응답 반환
106+ if (userByRoomPartList .isEmpty ()) {
107+ return GlobalResponse .error (ErrorCode .NONE_ROOM );
108+ }
109+
110+ return GlobalResponse .success ("사용자가 들어가 있는 방 리스트 조회 성공." ,userByRoomPartList );
92111 } else {
93- throw new IllegalArgumentException ("User not logged in ." );
112+ throw new IllegalArgumentException ("로그인 후에 이용해 주세요 ." );
94113 }
95114 }
96115
@@ -105,9 +124,9 @@ public GlobalResponse<Object> outRoom(
105124 CustomOAuth2User principal = (CustomOAuth2User ) authentication .getPrincipal ();
106125 Long userId = principal .getId (); // getId()를 통해 userId를 추출
107126 chatRoomService .outRoom (userId , roomId );
108- return GlobalResponse .success ();
127+ return GlobalResponse .success ("채팅방을 나갔습니다." );
109128 } else {
110- throw new IllegalArgumentException ("User not logged in ." );
129+ throw new IllegalArgumentException ("로그인 후에 이용해 주세요 ." );
111130 }
112131 }
113132
@@ -122,9 +141,9 @@ public GlobalResponse<Object> deleteRoom(
122141 CustomOAuth2User principal = (CustomOAuth2User ) authentication .getPrincipal ();
123142 Long userId = principal .getId (); // getId()를 통해 userId를 추출
124143 chatRoomService .deleteRoom (userId , roomId );
125- return GlobalResponse .success ();
144+ return GlobalResponse .success ("채팅방을 삭제했습니다." );
126145 } else {
127- throw new IllegalArgumentException ("User not logged in ." );
146+ throw new IllegalArgumentException ("로그인 후에 이용해 주세요 ." );
128147 }
129148 }
130149
0 commit comments