33import com .thefirsttake .app .chat .dto .request .ChatMessageRequest ;
44import com .thefirsttake .app .chat .entity .ChatRoom ;
55import com .thefirsttake .app .chat .service .ChatMessageProcessorService ;
6- import com .thefirsttake .app .chat .service .ChatMessageSaveService ;
6+ // import com.thefirsttake.app.chat.service.ChatMessageSaveService;
77import com .thefirsttake .app .chat .service .ChatRoomService ;
88import com .thefirsttake .app .chat .service .SendMessageWorkerService ;
9- import com .thefirsttake .app .chat .service .worker .ChatMessageWorkerService ;
9+ // import com.thefirsttake.app.chat.service.worker.ChatMessageWorkerService;
1010import com .thefirsttake .app .common .response .CommonResponse ;
1111import com .thefirsttake .app .common .user .entity .UserEntity ;
1212import com .thefirsttake .app .common .user .service .UserSessionService ;
2626@ RequiredArgsConstructor
2727public class ChatMessageController {
2828 private final ChatMessageProcessorService chatMessageProcessorService ;
29- private final ChatMessageSaveService chatMessageSaveService ;
29+ // private final ChatMessageSaveService chatMessageSaveService;
3030 private final SendMessageWorkerService sendMessageWorkerService ;
31- private final ChatMessageWorkerService chatMessageWorkerService ;
31+ // private final ChatMessageWorkerService chatMessageWorkerService;
3232 private final UserSessionService userSessionService ;
3333 private final ChatRoomService chatRoomService ;
3434
@@ -125,11 +125,12 @@ public CommonResponse sendChatMessage(@RequestParam("roomId") Long roomId, @Requ
125125 // 1. roomid를 바탕으로 -> 채팅방 확인 -> 유저 확인
126126 UserEntity userEntity =chatRoomService .getUserEntityByRoomId (roomId );
127127 // 2. 메시지 PostgreSQL에 저장
128+ Long savedId =chatRoomService .saveUserMessage (userEntity ,chatMessageRequest ,roomId );
128129 // 3. Redis 워커 큐에 푸시
129130
130131 // 1. 유저 확인/생성
131132 // 2. 채팅방 확인/생성
132- return CommonResponse .success (userEntity . getId () );
133+ return CommonResponse .success (savedId );
133134// // 1. PostgreSQL 저장
134135// Long savedId = chatMessageSaveService.saveUserMessage(sessionId, chatMessageRequest);
135136//
@@ -148,84 +149,86 @@ public CommonResponse sendChatMessage(@RequestParam("roomId") Long roomId, @Requ
148149
149150 }
150151
151- @ Operation (
152- summary = "채팅 응답 메시지 수신" ,
153- description = "Redis 큐에서 세션에 해당하는 응답 메시지가 있는 경우, 여러 개의 메시지를 한번에 꺼내 반환합니다." ,
154- responses = {
155- @ io .swagger .v3 .oas .annotations .responses .ApiResponse (
156- responseCode = "200" ,
157- description = "응답 메시지 수신 성공" ,
158- content = @ Content (
159- mediaType = "application/json" ,
160- schema = @ Schema (implementation = CommonResponse .class ),
161- examples = @ ExampleObject (
162- name = "성공 응답 예시" ,
163- summary = "Redis에서 가져온 응답 메시지 리스트" ,
164- value = """
165- {
166- "status": "success",
167- "message": "요청 성공",
168- "data": [
169- "당신의 소개팅은 어떤 분위기를 원하세요? 좀 더 캐주얼하고 편안한 느낌을 원하시면 깔끔한 셔츠와 슬랙스, 약간 더 포멀한 느낌을 원하시면 셔츠와 블레이저를 추천드릴게요.1번째 AI",
170- "내일 소개팅이라면 깔끔하고 세련된 느낌이 좋겠어요. 단정한 셔츠에 슬림한 팬츠를 추천드려요. 색상은 무난하면서도 포인트를 줄 수 있는 베이지, 하얀색 또는 연한 파스텔 톤이 좋아요. 액세서리는 과하지 않게 심플한 목걸이나 귀걸이로 마무리하면 자연스럽고 매력적으로 보일 거예요. 편안하면서도 신경 쓴 모습이 가장 좋아요!2번째 AI"
171- ]
172- }
173- """
174- )
175- )
176- ),
177- @ io .swagger .v3 .oas .annotations .responses .ApiResponse (
178- responseCode = "400" ,
179- description = "세션 없음 또는 응답 없음" ,
180- content = @ Content (
181- mediaType = "application/json" ,
182- examples = {
183- @ ExampleObject (
184- name = "세션 없음 예시" ,
185- summary = "세션이 없을 경우" ,
186- value = """
187- {
188- "status": "fail",
189- "message": "세션이 존재하지 않습니다.",
190- "data": null
191- }
192- """
193- ),
194- @ ExampleObject (
195- name = "응답 없음 예시" ,
196- summary = "아직 응답이 Redis에 없는 경우" ,
197- value = """
198- {
199- "status": "fail",
200- "message": "응답이 아직 없습니다.",
201- "data": null
202- }
203- """
204- )
205- }
206- )
207- )
208- }
209- )
210- @ GetMapping ("/receive" )
211- public CommonResponse receiveChatMessage (HttpServletRequest httpRequest ) {
212- HttpSession session = httpRequest .getSession (false );
213- if (session == null ) {
214- return CommonResponse .fail ("세션이 존재하지 않습니다." );
215- }
216-
217- String sessionId = session .getId ();
218- List <String > responseMessage =chatMessageWorkerService .processChatQueue (sessionId );
219- // String redisKey = "chat_response:" + sessionId;
152+ // @Operation(
153+ // summary = "채팅 응답 메시지 수신",
154+ // description = "Redis 큐에서 세션에 해당하는 응답 메시지가 있는 경우, 여러 개의 메시지를 한번에 꺼내 반환합니다.",
155+ // responses = {
156+ // @io.swagger.v3.oas.annotations.responses.ApiResponse(
157+ // responseCode = "200",
158+ // description = "응답 메시지 수신 성공",
159+ // content = @Content(
160+ // mediaType = "application/json",
161+ // schema = @Schema(implementation = CommonResponse.class),
162+ // examples = @ExampleObject(
163+ // name = "성공 응답 예시",
164+ // summary = "Redis에서 가져온 응답 메시지 리스트",
165+ // value = """
166+ // {
167+ // "status": "success",
168+ // "message": "요청 성공",
169+ // "data": [
170+ // "당신의 소개팅은 어떤 분위기를 원하세요? 좀 더 캐주얼하고 편안한 느낌을 원하시면 깔끔한 셔츠와 슬랙스, 약간 더 포멀한 느낌을 원하시면 셔츠와 블레이저를 추천드릴게요.1번째 AI",
171+ // "내일 소개팅이라면 깔끔하고 세련된 느낌이 좋겠어요. 단정한 셔츠에 슬림한 팬츠를 추천드려요. 색상은 무난하면서도 포인트를 줄 수 있는 베이지, 하얀색 또는 연한 파스텔 톤이 좋아요. 액세서리는 과하지 않게 심플한 목걸이나 귀걸이로 마무리하면 자연스럽고 매력적으로 보일 거예요. 편안하면서도 신경 쓴 모습이 가장 좋아요!2번째 AI"
172+ // ]
173+ // }
174+ // """
175+ // )
176+ // )
177+ // ),
178+ // @io.swagger.v3.oas.annotations.responses.ApiResponse(
179+ // responseCode = "400",
180+ // description = "세션 없음 또는 응답 없음",
181+ // content = @Content(
182+ // mediaType = "application/json",
183+ // examples = {
184+ // @ExampleObject(
185+ // name = "세션 없음 예시",
186+ // summary = "세션이 없을 경우",
187+ // value = """
188+ // {
189+ // "status": "fail",
190+ // "message": "세션이 존재하지 않습니다.",
191+ // "data": null
192+ // }
193+ // """
194+ // ),
195+ // @ExampleObject(
196+ // name = "응답 없음 예시",
197+ // summary = "아직 응답이 Redis에 없는 경우",
198+ // value = """
199+ // {
200+ // "status": "fail",
201+ // "message": "응답이 아직 없습니다.",
202+ // "data": null
203+ // }
204+ // """
205+ // )
206+ // }
207+ // )
208+ // )
209+ // }
210+ // )
211+ // @GetMapping("/receive")
212+ // public CommonResponse receiveChatMessage(HttpServletRequest httpRequest) {
213+ // HttpSession session = httpRequest.getSession(false);
214+ // if (session == null) {
215+ // return CommonResponse.fail("세션이 존재하지 않습니다.");
216+ // }
220217//
221- // // Redis에서 메시지를 pop (꺼내고 제거)
222- // String responseMessage = redisTemplate.opsForList().leftPop(redisKey );
218+ // String sessionId = session.getId();
219+ // List< String> responseMessage=chatMessageWorkerService.processChatQueue(sessionId );
223220//
224- if (responseMessage == null ) {
225- return CommonResponse .fail ("응답이 아직 없습니다." ); // 또는 return ResponseEntity.noContent().build();
226- }
227- return CommonResponse .success (responseMessage );
228- }
221+ //
222+ //// String redisKey = "chat_response:" + sessionId;
223+ ////
224+ //// // Redis에서 메시지를 pop (꺼내고 제거)
225+ //// String responseMessage = redisTemplate.opsForList().leftPop(redisKey);
226+ ////
227+ // if (responseMessage == null) {
228+ // return CommonResponse.fail("응답이 아직 없습니다."); // 또는 return ResponseEntity.noContent().build();
229+ // }
230+ // return CommonResponse.success(responseMessage);
231+ // }
229232
230233
231234}
0 commit comments