-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChatbotController.java
30 lines (25 loc) · 1.13 KB
/
ChatbotController.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.server.computerscience.chatbot.controller;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.server.computerscience.chatbot.dto.request.ChatBotRequestDto;
import com.server.computerscience.chatbot.dto.response.ChatBotResponseDto;
import com.server.computerscience.chatbot.service.ChatbotService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
@RestController
@Api(tags = {"챗봇"})
@RequiredArgsConstructor
public class ChatbotController {
private final ChatbotService chatbotService;
@PostMapping("/chat/text")
public ResponseEntity<ChatBotResponseDto> chat(
@RequestBody ChatBotRequestDto chatBotRequestDto,
@AuthenticationPrincipal OAuth2User user
) {
return ResponseEntity.ok(ChatBotResponseDto.from(chatbotService.talkToAssistant(chatBotRequestDto, user)));
}
}