-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] 세션 만드는 createSession, 메시지 전송하고 응답 받는 createMessage 메소드 구현
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/main/java/com/fav/daengnyang/domain/chatbot/controller/ChatbotController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.fav.daengnyang.domain.chatbot.controller; | ||
|
||
import com.fav.daengnyang.domain.chatbot.service.ChatbotService; | ||
import com.fav.daengnyang.domain.chatbot.service.dto.request.CreateMessageRequest; | ||
import com.fav.daengnyang.domain.chatbot.service.dto.response.MessageResponse; | ||
import com.fav.daengnyang.global.auth.dto.MemberPrincipal; | ||
import com.fav.daengnyang.global.dto.response.ExceptionResponse; | ||
import com.fav.daengnyang.global.web.dto.response.SuccessResponse; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RequestMapping("/chatbots") | ||
@RestController | ||
public class ChatbotController { | ||
|
||
private final ChatbotService chatbotService; | ||
|
||
// 챗봇에게 메시지 보내고 응답 받기 | ||
@PostMapping | ||
public SuccessResponse<?> createMessage( | ||
@AuthenticationPrincipal MemberPrincipal memberPrincipal, | ||
@Valid @RequestBody CreateMessageRequest messageRequest | ||
) throws InterruptedException { | ||
MessageResponse response = chatbotService.getMessage(memberPrincipal.getMemberId(), messageRequest); | ||
return SuccessResponse.ok(response); | ||
} | ||
|
||
// 챗봇에게 처음 메시지 보내기(새로운 세션 만들기) | ||
@PostMapping("/session") | ||
public SuccessResponse<?> createSession( | ||
@AuthenticationPrincipal MemberPrincipal memberPrincipal | ||
){ | ||
chatbotService.createSession(memberPrincipal.getMemberId()); | ||
return SuccessResponse.created("세션 생성에 성공했습니다."); | ||
} | ||
|
||
|
||
} |