diff --git a/src/main/java/com/twentythree/peech/script/controller/ScriptController.java b/src/main/java/com/twentythree/peech/script/controller/ScriptController.java index 08538fb1..163885f8 100644 --- a/src/main/java/com/twentythree/peech/script/controller/ScriptController.java +++ b/src/main/java/com/twentythree/peech/script/controller/ScriptController.java @@ -4,7 +4,7 @@ import com.twentythree.peech.script.dto.response.ExpectedTimeResponseDTO; import com.twentythree.peech.script.dto.response.MajorScriptsResponseDTO; import com.twentythree.peech.script.dto.response.MinorScriptsResponseDTO; -import com.twentythree.peech.script.dto.response.SaveScriptAndSentenceResponseDTO; +import com.twentythree.peech.script.dto.response.SaveScriptAndSentencesResponseDTO; import com.twentythree.peech.script.service.ScriptSentenceFacade; import com.twentythree.peech.script.service.ScriptService; import io.swagger.v3.oas.annotations.Operation; @@ -18,29 +18,38 @@ public class ScriptController implements SwaggerScriptInterface{ private final ScriptSentenceFacade scriptSentenceFacade; private final ScriptService scriptService; - @Operation(summary = "문단들 입력", description = "버전 생성 및 저장, 대본 저장, 문장 저장.") - @PostMapping("/api/v1/script") - public SaveScriptAndSentenceResponseDTO saveScriptAndSentence(@RequestBody ParagraphsRequestDTO request) { - Long scriptId = scriptSentenceFacade.createScriptAndSentence(request.themeId(), request.paragraphs()); + @Operation(summary = "새로운 대본 생성", + description = "특정 주제를 themeId로 path에 넣고, 스크립트를 문단들로 나누어 RequestBody에 입력하면 새로운 버전, 대본, 문장 생성 및 저장.") + @PostMapping("/api/v1/themes/{themeId}/script") + public SaveScriptAndSentencesResponseDTO saveScriptAndSentences(@PathVariable("themeId") Long themeId, + @RequestBody ParagraphsRequestDTO request) { + Long scriptId = scriptSentenceFacade.createScriptAndSentences(themeId, request.paragraphs()); - return new SaveScriptAndSentenceResponseDTO(scriptId); + return new SaveScriptAndSentencesResponseDTO(scriptId); } - @GetMapping("/api/v1/script") - public ExpectedTimeResponseDTO getScriptAndSentenceExpectedTime(@RequestParam("scriptId") Long scriptId) { + @Operation(summary = "입력한 스크립트에 대한 예상 시간 가져오기", + description = "특정 주제의 스크립트를 themeId, scriptId로 path에 입력하면 전체 예상시간, 문단별 예상시간들을 응답") + @GetMapping("/api/v1/themes/{themeId}/scripts/{scriptId}/time") + public ExpectedTimeResponseDTO getScriptAndParagraphsExpectedTime(@PathVariable("themeId") Long themeId, + @PathVariable("scriptId") Long scriptId) { return scriptSentenceFacade.getScriptAndSentence(scriptId); } + @Operation(summary = "입력(메이저) 대본 가져오기", + description = "특정 주제의 themeId를 path에 넣으면 특정 주제에 대해 입력한(메이저) 스크립트들을 응답한다.") @Override - @GetMapping("/api/v1/script/{themeId}") - public MajorScriptsResponseDTO getMajorScript(@PathVariable("themeId") Long themeId) { - MajorScriptsResponseDTO majorScript = scriptService.getMajorScript(themeId); - return majorScript; + @GetMapping("/api/v1/themes/{themeId}/scripts/majors") + public MajorScriptsResponseDTO getMajorScripts(@PathVariable("themeId") Long themeId) { + MajorScriptsResponseDTO majorScripts = scriptService.getMajorScripts(themeId); + return majorScripts; } + @Operation(summary = "측정(마이너) 대본 가져오기", + description = "특정 주제의 themeId와 메이저 대본의 버전(majorVersion)을 path에 입력하면 특정주제의 입력대본을 가지고 연습하여 나온 음성 스크립트들을 응답한다.") @Override - @GetMapping("/api/v1/script/{themeId}/{majorVersion}") - public MinorScriptsResponseDTO getMinorScript(@PathVariable("themeId") Long themeId, @PathVariable("majorVersion") Long majorVersion) { - return scriptService.getMinorScript(themeId, majorVersion); + @GetMapping("/api/v1/themes/{themeId}/scripts/{majorVersion}/minors") + public MinorScriptsResponseDTO getMinorScripts(@PathVariable("themeId") Long themeId, @PathVariable("majorVersion") Long majorVersion) { + return scriptService.getMinorScripts(themeId, majorVersion); } } diff --git a/src/main/java/com/twentythree/peech/script/controller/SwaggerScriptInterface.java b/src/main/java/com/twentythree/peech/script/controller/SwaggerScriptInterface.java index 3240f94d..52dea12e 100644 --- a/src/main/java/com/twentythree/peech/script/controller/SwaggerScriptInterface.java +++ b/src/main/java/com/twentythree/peech/script/controller/SwaggerScriptInterface.java @@ -4,27 +4,28 @@ import com.twentythree.peech.script.dto.response.ExpectedTimeResponseDTO; import com.twentythree.peech.script.dto.response.MajorScriptsResponseDTO; import com.twentythree.peech.script.dto.response.MinorScriptsResponseDTO; -import com.twentythree.peech.script.dto.response.SaveScriptAndSentenceResponseDTO; +import com.twentythree.peech.script.dto.response.SaveScriptAndSentencesResponseDTO; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; public interface SwaggerScriptInterface { - @ApiResponse(responseCode = "201", description = "성공", content = {@Content(schema = @Schema(implementation = SaveScriptAndSentenceResponseDTO.class), mediaType = "application/json")}) + @ApiResponse(responseCode = "201", description = "성공", content = {@Content(schema = @Schema(implementation = SaveScriptAndSentencesResponseDTO.class), mediaType = "application/json")}) @ApiResponse(responseCode = "400", description = "실패", content = {@Content(schema = @Schema(implementation = Error.class), mediaType = "application/json")}) - SaveScriptAndSentenceResponseDTO saveScriptAndSentence(@RequestBody ParagraphsRequestDTO request); + SaveScriptAndSentencesResponseDTO saveScriptAndSentences(@PathVariable("themeId") Long themeId, + @RequestBody ParagraphsRequestDTO request); @ApiResponse(responseCode = "200", description = "성공", content = {@Content(schema = @Schema(implementation = ExpectedTimeResponseDTO.class), mediaType = "application/json")}) @ApiResponse(responseCode = "400", description = "실패", content = {@Content(schema = @Schema(implementation = Error.class), mediaType = "application/json")}) - ExpectedTimeResponseDTO getScriptAndSentenceExpectedTime(@RequestParam("scriptId") Long scriptId); + ExpectedTimeResponseDTO getScriptAndParagraphsExpectedTime(@PathVariable("themeId") Long themeId, + @PathVariable("scriptId") Long scriptId); @ApiResponse(responseCode = "200", description = "success", content = {@Content(schema = @Schema(implementation = MajorScriptsResponseDTO.class), mediaType = "application/json")}) - MajorScriptsResponseDTO getMajorScript(@PathVariable Long themeId); + MajorScriptsResponseDTO getMajorScripts(@PathVariable Long themeId); @ApiResponse(responseCode = "200", description = "success", content = {@Content(schema = @Schema(implementation = MajorScriptsResponseDTO.class), mediaType = "application/json")}) - MinorScriptsResponseDTO getMinorScript(@PathVariable Long majorVersion, @PathVariable Long themeId); + MinorScriptsResponseDTO getMinorScripts(@PathVariable Long majorVersion, @PathVariable Long themeId); } diff --git a/src/main/java/com/twentythree/peech/script/controller/ThemeController.java b/src/main/java/com/twentythree/peech/script/controller/ThemeController.java index c70ad41a..0cf482f2 100644 --- a/src/main/java/com/twentythree/peech/script/controller/ThemeController.java +++ b/src/main/java/com/twentythree/peech/script/controller/ThemeController.java @@ -32,7 +32,7 @@ public ThemeIdResponseDTO saveTheme(@RequestBody ThemeTitleRequestDTO request, @ } @Override - @GetMapping("/api/v1/theme") + @GetMapping("/api/v1/themes") public ThemesResponseDTO getThemes(@LoginUserId UserIdDTO userIdDTO) { Long userId = userIdDTO.userId(); diff --git a/src/main/java/com/twentythree/peech/script/dto/request/ParagraphsRequestDTO.java b/src/main/java/com/twentythree/peech/script/dto/request/ParagraphsRequestDTO.java index ccf864d5..865c3441 100644 --- a/src/main/java/com/twentythree/peech/script/dto/request/ParagraphsRequestDTO.java +++ b/src/main/java/com/twentythree/peech/script/dto/request/ParagraphsRequestDTO.java @@ -1,5 +1,5 @@ package com.twentythree.peech.script.dto.request; -public record ParagraphsRequestDTO(Long themeId, String[] paragraphs) { +public record ParagraphsRequestDTO(String[] paragraphs) { } \ No newline at end of file diff --git a/src/main/java/com/twentythree/peech/script/dto/response/SaveScriptAndSentenceResponseDTO.java b/src/main/java/com/twentythree/peech/script/dto/response/SaveScriptAndSentenceResponseDTO.java deleted file mode 100644 index 037a3d22..00000000 --- a/src/main/java/com/twentythree/peech/script/dto/response/SaveScriptAndSentenceResponseDTO.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.twentythree.peech.script.dto.response; - -public record SaveScriptAndSentenceResponseDTO(Long scriptId) { -} diff --git a/src/main/java/com/twentythree/peech/script/dto/response/SaveScriptAndSentencesResponseDTO.java b/src/main/java/com/twentythree/peech/script/dto/response/SaveScriptAndSentencesResponseDTO.java new file mode 100644 index 00000000..c81e1581 --- /dev/null +++ b/src/main/java/com/twentythree/peech/script/dto/response/SaveScriptAndSentencesResponseDTO.java @@ -0,0 +1,4 @@ +package com.twentythree.peech.script.dto.response; + +public record SaveScriptAndSentencesResponseDTO(Long scriptId) { +} diff --git a/src/main/java/com/twentythree/peech/script/service/ScriptSentenceFacade.java b/src/main/java/com/twentythree/peech/script/service/ScriptSentenceFacade.java index 7e3713f6..3f9a23f4 100644 --- a/src/main/java/com/twentythree/peech/script/service/ScriptSentenceFacade.java +++ b/src/main/java/com/twentythree/peech/script/service/ScriptSentenceFacade.java @@ -17,7 +17,7 @@ public class ScriptSentenceFacade { private final SentenceService sentenceService; @Transactional - public Long createScriptAndSentence(Long themeId, String[] paragraphs) { + public Long createScriptAndSentences(Long themeId, String[] paragraphs) { SaveScriptDTO saveScripDTO = scriptService.saveInputScript(themeId, paragraphs); List sentenceIds = sentenceService.saveInputSentencesByParagraphs(saveScripDTO.scriptEntity(), paragraphs); diff --git a/src/main/java/com/twentythree/peech/script/service/ScriptService.java b/src/main/java/com/twentythree/peech/script/service/ScriptService.java index 9d711d15..1f4df329 100644 --- a/src/main/java/com/twentythree/peech/script/service/ScriptService.java +++ b/src/main/java/com/twentythree/peech/script/service/ScriptService.java @@ -65,7 +65,7 @@ public LocalTime getInputExpectedScriptTime(Long scriptId) { return scriptEntity.getTotalExpectTime(); } - public MajorScriptsResponseDTO getMajorScript(Long themeId) { + public MajorScriptsResponseDTO getMajorScripts(Long themeId) { List scripts = scriptRepository.findMajorScriptByThemeId(themeId); List majorScript = new ArrayList<>(); for (ScriptEntity script : scripts) { @@ -75,7 +75,7 @@ public MajorScriptsResponseDTO getMajorScript(Long themeId) { return new MajorScriptsResponseDTO(majorScript); } - public MinorScriptsResponseDTO getMinorScript(Long themeId, Long majorVersion) { + public MinorScriptsResponseDTO getMinorScripts(Long themeId, Long majorVersion) { List scripts = scriptRepository.findMinorScriptByThemeIdAndMajorVersion(themeId, majorVersion); List minorScripts = new ArrayList<>(); diff --git a/src/main/java/com/twentythree/peech/user/controller/UserController.java b/src/main/java/com/twentythree/peech/user/controller/UserController.java index 819609c9..66ed9d0a 100644 --- a/src/main/java/com/twentythree/peech/user/controller/UserController.java +++ b/src/main/java/com/twentythree/peech/user/controller/UserController.java @@ -17,7 +17,7 @@ public class UserController implements SwaggerUserController{ private final UserService userService; @Operation(summary = "유저 가입", - description = "deviceId를 CreateUserRequestDTO에 담아 요청하면 생성된 UserId를 CreteUserResponseDTO에 담아 응답한다.") + description = "deviceId를 RequestBody에 담아 요청하면 새로운 유저를 생성하고 생성된 UserId를 응답한다.") @Override @PostMapping("api/v1/user") public CreateUserResponseDTO createUser(@RequestBody CreateUserRequestDTO request) {