99import jakarta .validation .Valid ;
1010import lombok .RequiredArgsConstructor ;
1111import org .springframework .data .domain .Pageable ;
12- import org .springframework .http .ResponseEntity ;
1312import org .springframework .security .core .Authentication ;
1413import org .springframework .security .core .context .SecurityContextHolder ;
1514import org .springframework .security .oauth2 .client .authentication .OAuth2AuthenticationToken ;
@@ -57,23 +56,23 @@ public GlobalResponse<Object> joinRoom(@PathVariable Long roomId) {
5756 // 전체 리스트
5857 @ GetMapping ("/room" )
5958 @ LoginCheck
60- public ResponseEntity <Object > roomList (Pageable pageable ) {
59+ public GlobalResponse <Object > roomList (Pageable pageable ) {
6160 List <ChatRoomDto > roomList = chatRoomService .getRoomList (pageable );
62- return ResponseEntity . ok (). body (roomList );
61+ return GlobalResponse . success (roomList );
6362 }
6463
6564 // 사용자(자신)가 생성한 방 리스트 조회
6665 @ GetMapping ("/room/creator" )
6766 @ LoginCheck
68- public ResponseEntity <Object > getByUserRoomList (Pageable pageable ) {
67+ public GlobalResponse <Object > getByUserRoomList (Pageable pageable ) {
6968 Authentication authentication = SecurityContextHolder .getContext ().getAuthentication ();
7069
7170 if (authentication instanceof OAuth2AuthenticationToken ) {
7271 CustomOAuth2User principal = (CustomOAuth2User ) authentication .getPrincipal ();
7372 Long userId = principal .getId (); // getId()를 통해 userId를 추출
7473
7574 List <ChatRoomDto > userByRoomList = chatRoomService .getUserByRoomList (userId , pageable );
76- return ResponseEntity . ok (). body (userByRoomList );
75+ return GlobalResponse . success (userByRoomList );
7776 } else {
7877 throw new IllegalArgumentException ("User not logged in." );
7978 }
@@ -82,35 +81,35 @@ public ResponseEntity<Object> getByUserRoomList(Pageable pageable) {
8281 // 사용자(자신)가 들어가 있는 방 리스트 조회
8382 @ GetMapping ("/room/part" )
8483 @ LoginCheck
85- public ResponseEntity <Object > getByUserRoomPartList (Pageable pageable ) {
84+ public GlobalResponse <Object > getByUserRoomPartList (Pageable pageable ) {
8685 Authentication authentication = SecurityContextHolder .getContext ().getAuthentication ();
8786
8887 if (authentication instanceof OAuth2AuthenticationToken ) {
8988 CustomOAuth2User principal = (CustomOAuth2User ) authentication .getPrincipal ();
9089 Long userId = principal .getId (); // getId()를 통해 userId를 추출
9190 List <ChatRoomDto > userByRoomPartList = chatRoomService .getUserByRoomPartList (userId , pageable );
92- return ResponseEntity . ok (). body (userByRoomPartList );
91+ return GlobalResponse . success (userByRoomPartList );
9392 } else {
9493 throw new IllegalArgumentException ("User not logged in." );
9594 }
9695 }
9796
98- // // 채팅방 나가기
99- // @DeleteMapping("/room/out/{roomId}")
100- // @LoginCheck
101- // public ResponseEntity <Object> outRoom(
102- // @PathVariable Long roomId) {
103- // Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
104- //
105- // if (authentication instanceof OAuth2AuthenticationToken) {
106- // CustomOAuth2User principal = (CustomOAuth2User) authentication.getPrincipal();
107- // Long userId = principal.getId(); // getId()를 통해 userId를 추출
108- // chatRoomService.outRoom(userId, roomId);
109- // return ResponseEntity.ok().body(" success" );
110- // } else {
111- // throw new IllegalArgumentException("User not logged in.");
112- // }
113- // }
97+ // 채팅방 나가기
98+ @ DeleteMapping ("/room/out/{roomId}" )
99+ @ LoginCheck
100+ public GlobalResponse <Object > outRoom (
101+ @ PathVariable Long roomId ) {
102+ Authentication authentication = SecurityContextHolder .getContext ().getAuthentication ();
103+
104+ if (authentication instanceof OAuth2AuthenticationToken ) {
105+ CustomOAuth2User principal = (CustomOAuth2User ) authentication .getPrincipal ();
106+ Long userId = principal .getId (); // getId()를 통해 userId를 추출
107+ chatRoomService .outRoom (userId , roomId );
108+ return GlobalResponse . success ( );
109+ } else {
110+ throw new IllegalArgumentException ("User not logged in." );
111+ }
112+ }
114113//
115114// // 채팅방 삭제
116115// @DeleteMapping("/room/delete/{roomId}")
0 commit comments