From 27d62871ddde84a778e2cb73b9cff76f094728a9 Mon Sep 17 00:00:00 2001 From: kms Date: Thu, 28 Sep 2023 11:22:48 +0900 Subject: [PATCH] :sparkles: feat: create test api #15 --- .../watchboard/controller/GraphController.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/smart/watchboard/controller/GraphController.java b/src/main/java/com/smart/watchboard/controller/GraphController.java index 469b262..46caa08 100644 --- a/src/main/java/com/smart/watchboard/controller/GraphController.java +++ b/src/main/java/com/smart/watchboard/controller/GraphController.java @@ -1,5 +1,6 @@ package com.smart.watchboard.controller; +import com.smart.watchboard.common.support.AudioConcatenator; import com.smart.watchboard.common.support.AwsS3Uploader; import com.smart.watchboard.service.FileService; import io.swagger.v3.oas.annotations.Operation; @@ -12,22 +13,33 @@ import org.springframework.web.client.RestTemplate; import org.springframework.web.multipart.MultipartFile; +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.UnsupportedAudioFileException; +import java.io.IOException; + @RestController @RequestMapping("/graph") @Tag(name = "그래프 API", description = "그래프 관련 API(mock)") @RequiredArgsConstructor @Slf4j public class GraphController { - - //private final RestTemplate restTemplate; + private final AwsS3Uploader awsS3Uploader; + private final AudioConcatenator audioConcatenator; private final String aiServerUrl = ""; @PostMapping("/{documentID}") @Operation(summary = "마인드맵 생성", description = "음성 데이터를 받아 ai 서버에 마인드맵 요청한다.") public ResponseEntity getMindmap(@PathVariable(value = "documentID") long documentId, @RequestParam("audioFile") MultipartFile audioFile, @RequestParam(value = "fileID", required = false) Long fileId, @RequestHeader("Authorization") String accessToken) { - awsS3Uploader.uploadImage(audioFile, documentId, fileId); + awsS3Uploader.uploadFile(audioFile, documentId, fileId); + //awsS3Uploader.deleteFile(); return new ResponseEntity<>("{\"root\":1,\"keywords\":[\"나는\",\"eat\",\"food\",\"today\"],\"graph\":{\"1\":[0,2],\"2\":[3]}}", HttpStatus.OK); } + + @PostMapping("/abc") + public ResponseEntity test(@RequestParam("audioFile1") MultipartFile audioFile1, @RequestParam(value = "fileID", required = false) Long fileId) throws UnsupportedAudioFileException, IOException { + audioConcatenator.concatenateAudioFiles(audioFile1, fileId); + return new ResponseEntity<>("", HttpStatus.OK); + } }