From 4047dca35ee56b63bbf78ce47418d885dbc83f58 Mon Sep 17 00:00:00 2001 From: kms Date: Tue, 7 Nov 2023 13:04:08 +0900 Subject: [PATCH] :hammer: feat: add create summary #38 --- .../controller/AudioFileController.java | 24 ++++++++++++------- .../controller/LearningFileController.java | 8 +++---- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/smart/watchboard/controller/AudioFileController.java b/src/main/java/com/smart/watchboard/controller/AudioFileController.java index 1919ace..dc99217 100644 --- a/src/main/java/com/smart/watchboard/controller/AudioFileController.java +++ b/src/main/java/com/smart/watchboard/controller/AudioFileController.java @@ -109,7 +109,7 @@ public ResponseEntity getAudioFile(@PathVariable(value = "documentID") long d } @PostMapping("/testffff") - public ResponseEntity test(@RequestHeader("Authorization") String accessToken) throws UnsupportedAudioFileException, IOException { + public ResponseEntity test(@RequestParam("audioFile") MultipartFile audioFile, @RequestHeader("Authorization") String accessToken) throws UnsupportedAudioFileException, IOException { String body = """ { "segments":[ @@ -144,14 +144,20 @@ public ResponseEntity test(@RequestHeader("Authorization") String accessToken ] } """; - ResponseEntity response1 = new ResponseEntity<>(body, HttpStatus.OK); - List data = sttService.getSTTData(response1); - System.out.println(data.get(0).getText()); - lectureNoteService.createLectureNote(100L, data, "aa"); - String path = "naver.com"; - SttDto body2 = fileService.createResponseBody(path, data); - ResponseEntity ss = new ResponseEntity<>(body2, HttpStatus.OK); - return ss; +// ResponseEntity response1 = new ResponseEntity<>(body, HttpStatus.OK); +// List data = sttService.getSTTData(response1); +// System.out.println(data.get(0).getText()); +// lectureNoteService.createLectureNote(100L, data, "aa"); +// String path = "naver.com"; +// SttDto body2 = fileService.createResponseBody(path, data); +// ResponseEntity ss = new ResponseEntity<>(body2, HttpStatus.OK); +// return ss; + S3Dto s3Dto = new S3Dto(audioFile, 26L); + String path = awsS3Uploader.uploadFile(s3Dto); + int startIndex = path.indexOf("application/pdf/") + "application/pdf/".length(); + String extractedString = path.substring(startIndex); + System.out.println(extractedString); + return new ResponseEntity<>(HttpStatus.OK); } } diff --git a/src/main/java/com/smart/watchboard/controller/LearningFileController.java b/src/main/java/com/smart/watchboard/controller/LearningFileController.java index 70c6493..8aecbb4 100644 --- a/src/main/java/com/smart/watchboard/controller/LearningFileController.java +++ b/src/main/java/com/smart/watchboard/controller/LearningFileController.java @@ -6,10 +6,7 @@ import com.smart.watchboard.dto.FileDto; import com.smart.watchboard.dto.KeywordsDto; import com.smart.watchboard.dto.S3Dto; -import com.smart.watchboard.service.FileService; -import com.smart.watchboard.service.MindmapService; -import com.smart.watchboard.service.RequestService; -import com.smart.watchboard.service.WhiteboardService; +import com.smart.watchboard.service.*; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -33,12 +30,15 @@ public class LearningFileController { private final FileService fileService; private final RequestService requestService; private final WhiteboardService whiteboardService; + private final SummaryService summaryService; @PostMapping("/{documentID}/pdf") public ResponseEntity uploadLearningFile(@PathVariable(value = "documentID") long documentId, @RequestParam("pdf") MultipartFile pdfFile, @RequestHeader("Authorization") String accessToken) throws UnsupportedAudioFileException, IOException { S3Dto s3Dto = new S3Dto(pdfFile, documentId); String path = awsS3Uploader.uploadFile(s3Dto); ResponseEntity responseEntity = requestService.requestPdfKeywords(path); + String summary = requestService.requestPdfSummary(path); + summaryService.createSummary(documentId, summary); whiteboardService.setDataType(documentId, "pdf"); return new ResponseEntity<>(responseEntity.getBody(), HttpStatus.OK);