Skip to content

Commit

Permalink
Merge pull request #126 from twenty-three-23/feature/TT-169-fix-hiera…
Browse files Browse the repository at this point in the history
…rchy-path

TT-169 controller 계층 구조 변경
  • Loading branch information
snacktime81 authored Jul 3, 2024
2 parents abd96f5 + 88351cc commit ce78d59
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.twentythree.peech.script.dto.request;


public record ParagraphsRequestDTO(Long themeId, String[] paragraphs) {
public record ParagraphsRequestDTO(String[] paragraphs) {
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.twentythree.peech.script.dto.response;

public record SaveScriptAndSentencesResponseDTO(Long scriptId) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Long> sentenceIds = sentenceService.saveInputSentencesByParagraphs(saveScripDTO.scriptEntity(), paragraphs);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public LocalTime getInputExpectedScriptTime(Long scriptId) {
return scriptEntity.getTotalExpectTime();
}

public MajorScriptsResponseDTO getMajorScript(Long themeId) {
public MajorScriptsResponseDTO getMajorScripts(Long themeId) {
List<ScriptEntity> scripts = scriptRepository.findMajorScriptByThemeId(themeId);
List<MajorScriptDTO> majorScript = new ArrayList<>();
for (ScriptEntity script : scripts) {
Expand All @@ -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<ScriptEntity> scripts = scriptRepository.findMinorScriptByThemeIdAndMajorVersion(themeId, majorVersion);

List<MinorScriptDTO> minorScripts = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ce78d59

Please sign in to comment.