9
9
import jakarta .validation .Valid ;
10
10
import lombok .RequiredArgsConstructor ;
11
11
import org .springframework .data .domain .Pageable ;
12
- import org .springframework .http .ResponseEntity ;
13
12
import org .springframework .security .core .Authentication ;
14
13
import org .springframework .security .core .context .SecurityContextHolder ;
15
14
import org .springframework .security .oauth2 .client .authentication .OAuth2AuthenticationToken ;
@@ -57,23 +56,23 @@ public GlobalResponse<Object> joinRoom(@PathVariable Long roomId) {
57
56
// 전체 리스트
58
57
@ GetMapping ("/room" )
59
58
@ LoginCheck
60
- public ResponseEntity <Object > roomList (Pageable pageable ) {
59
+ public GlobalResponse <Object > roomList (Pageable pageable ) {
61
60
List <ChatRoomDto > roomList = chatRoomService .getRoomList (pageable );
62
- return ResponseEntity . ok (). body (roomList );
61
+ return GlobalResponse . success (roomList );
63
62
}
64
63
65
64
// 사용자(자신)가 생성한 방 리스트 조회
66
65
@ GetMapping ("/room/creator" )
67
66
@ LoginCheck
68
- public ResponseEntity <Object > getByUserRoomList (Pageable pageable ) {
67
+ public GlobalResponse <Object > getByUserRoomList (Pageable pageable ) {
69
68
Authentication authentication = SecurityContextHolder .getContext ().getAuthentication ();
70
69
71
70
if (authentication instanceof OAuth2AuthenticationToken ) {
72
71
CustomOAuth2User principal = (CustomOAuth2User ) authentication .getPrincipal ();
73
72
Long userId = principal .getId (); // getId()를 통해 userId를 추출
74
73
75
74
List <ChatRoomDto > userByRoomList = chatRoomService .getUserByRoomList (userId , pageable );
76
- return ResponseEntity . ok (). body (userByRoomList );
75
+ return GlobalResponse . success (userByRoomList );
77
76
} else {
78
77
throw new IllegalArgumentException ("User not logged in." );
79
78
}
@@ -82,35 +81,35 @@ public ResponseEntity<Object> getByUserRoomList(Pageable pageable) {
82
81
// 사용자(자신)가 들어가 있는 방 리스트 조회
83
82
@ GetMapping ("/room/part" )
84
83
@ LoginCheck
85
- public ResponseEntity <Object > getByUserRoomPartList (Pageable pageable ) {
84
+ public GlobalResponse <Object > getByUserRoomPartList (Pageable pageable ) {
86
85
Authentication authentication = SecurityContextHolder .getContext ().getAuthentication ();
87
86
88
87
if (authentication instanceof OAuth2AuthenticationToken ) {
89
88
CustomOAuth2User principal = (CustomOAuth2User ) authentication .getPrincipal ();
90
89
Long userId = principal .getId (); // getId()를 통해 userId를 추출
91
90
List <ChatRoomDto > userByRoomPartList = chatRoomService .getUserByRoomPartList (userId , pageable );
92
- return ResponseEntity . ok (). body (userByRoomPartList );
91
+ return GlobalResponse . success (userByRoomPartList );
93
92
} else {
94
93
throw new IllegalArgumentException ("User not logged in." );
95
94
}
96
95
}
97
96
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
+ }
114
113
//
115
114
// // 채팅방 삭제
116
115
// @DeleteMapping("/room/delete/{roomId}")
0 commit comments