Skip to content

Commit

Permalink
[FEATURE] 세션 만드는 createSession, 메시지 전송하고 응답 받는 createMessage 메소드 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
sootudio committed Aug 28, 2024
1 parent 2370968 commit 053dcb2
Showing 1 changed file with 44 additions and 0 deletions.
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("세션 생성에 성공했습니다.");
}


}

0 comments on commit 053dcb2

Please sign in to comment.