Skip to content

Commit

Permalink
Merge pull request #396 from twenty-three-23/faeture/TT-499
Browse files Browse the repository at this point in the history
  • Loading branch information
ch8930 authored Nov 6, 2024
2 parents a369686 + 2bc3cfd commit 0a30644
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public ThemesResponseDTO getThemes() {
}

@GetMapping("api/v2/theme")
public ThemeIdResponseDTO getTheme(@AuthenticationPrincipal JWTAuthentication jwtAuthentication) {
return themeService.getThemeByUserId(jwtAuthentication.getUserId());
public ThemeIdResponseDTO getThemeId(@AuthenticationPrincipal JWTAuthentication jwtAuthentication) {
return themeService.getThemeIdByUserId(jwtAuthentication.getUserId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public interface ThemeRepository extends JpaRepository<ThemeEntity, Long> {
@Query("select v from VersionEntity v where v.themeEntity.themeId = :themeId")
Optional<List<VersionEntity>> findAllVersionsByThemeId(Long themeId);

@Query("select t.themeId from ThemeEntity t where t.userEntity.id = :userId")
@Query("select t.themeId from ThemeEntity t where t.userEntity.id = :userId and t.themeTitle = 'default'")
Long findThemeIdByUserId(Long userId);

@Query("select t from ThemeEntity t where t.userEntity.id = :userId and t.themeTitle = 'default'")
Optional<ThemeEntity> findDefaultThemeByUserId(Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public SaveScriptDTO saveInputScript(Long themeId, String[] paragraphs) {

LocalTime expectedTime = calculateExpectedTime(script);

ThemeEntity ThemeEntity = themeRepository.findById(themeId).orElseThrow(() -> new IllegalArgumentException("패키지 아이디가 잘못되었습니다."));
ThemeEntity ThemeEntity = themeRepository.findDefaultThemeByUserId(themeId).orElseThrow(() -> new IllegalArgumentException("패키지 아이디가 잘못되었습니다."));

Long latestMajorVersion = scriptRepository.findByMaxMajorVersionInthemeId(themeId);

Expand All @@ -78,7 +78,7 @@ public Mono<SaveSTTScriptVO> saveSTTScriptVO(Long themeId, Long scriptId, ClovaR

ScriptEntity scriptEntity = scriptRepository.findById(scriptId).orElseThrow(() -> new IllegalArgumentException("scriptId가 잘못 되었습니다."));

ThemeEntity ThemeEntity = themeRepository.findById(themeId).orElseThrow(() -> new IllegalArgumentException("패키지 아이디가 잘못되었습니다."));
ThemeEntity ThemeEntity = themeRepository.findDefaultThemeByUserId(themeId).orElseThrow(() -> new IllegalArgumentException("패키지 아이디가 잘못되었습니다."));

// 해당 스크립트의 MajorVersion과 MinorVersion을 가져옴
Long majorVersion = scriptEntity.getVersion().getMajorVersion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public ThemesResponseDTO getThemesByUserId(Long userId) {
}


public ThemeIdResponseDTO getThemeByUserId(Long userId) {
public ThemeIdResponseDTO getThemeIdByUserId(Long userId) {

if(themeRepository.findThemeIdByUserId(userId) == null) {
throw new IllegalArgumentException("생성된 기본폴더가 존재하지 않습니다.");
Expand Down

0 comments on commit 0a30644

Please sign in to comment.