Skip to content

Commit

Permalink
🔨 fix: add question service #63
Browse files Browse the repository at this point in the history
  • Loading branch information
noparamin committed Nov 18, 2023
1 parent 0ff1a3e commit cf703c1
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.smart.watchboard.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.smart.watchboard.domain.Answer;
import com.smart.watchboard.domain.Document;
import com.smart.watchboard.domain.Keyword;
import com.smart.watchboard.dto.AnswerDto;
Expand Down Expand Up @@ -37,6 +38,7 @@ public class GraphController {
private final SseService sseService;
private final KeywordService keywordService;
private final JwtService jwtService;
private final QuestionService questionService;
@PostMapping("/graph/{documentID}")
@Operation(summary = "마인드맵 생성", description = "ai 서버에 마인드맵 요청한다.")
public void createMindmap(@PathVariable(value = "documentID") long documentId, @RequestBody KeywordsBodyDto keywordsBodyDto, @RequestHeader("Authorization") String accessToken) throws JsonProcessingException {
Expand Down Expand Up @@ -94,11 +96,14 @@ public ResponseEntity<?> updateKeywords(@PathVariable(value = "documentID") long

@GetMapping("/documents/{documentID}/mindmap/keyword/{keywordLabel}")
@Operation(summary = "키워드 질문", description = "키워드 AI에 질문")
public ResponseEntity<?> getAnswer(@PathVariable(value = "documentID") long documentId, @PathVariable String keywordLabel, @RequestHeader("Authorization") String accessToken) throws JsonProcessingException {
//ResponseEntity<AnswerDto> responseEntity = requestService.requestAnswer(documentId, keywordLabel);
sseService.notifyAnswer(documentId, keywordLabel);
public ResponseEntity<AnswerDto> getAnswer(@PathVariable(value = "documentID") long documentId, @PathVariable String keywordLabel, @RequestHeader("Authorization") String accessToken) throws JsonProcessingException {
AnswerDto answerDto = questionService.getAnswer(documentId, keywordLabel);
if (answerDto == null) {
sseService.notifyAnswer(documentId, keywordLabel);
return new ResponseEntity<>(HttpStatus.ACCEPTED);
}

return new ResponseEntity<>(HttpStatus.OK);
return new ResponseEntity<>(answerDto, HttpStatus.OK);
}

@GetMapping(value = "documents/{documentID}/subscribe", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
Expand Down

0 comments on commit cf703c1

Please sign in to comment.