Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 FIX. 오류 해결 및 코드 수정 #15

Merged
merged 25 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3df9cd0
:sparkles: FEAT. 임시 파일 삭제 추가
junhaa May 1, 2024
2f80a5e
Merge branch 'dev' of https://github.com/Fairy-Taless/FairyTale-backe…
junhaa May 1, 2024
a58b3c1
:sparkles: FEAT. VoiceType.java 문장 음성 종류 추가
junhaa May 1, 2024
b9aab00
:art: CHORE. Fairytale.java import 추가
junhaa May 1, 2024
43af553
:sparkles: FEAT. 음성 추가 요청 DTO 추가
junhaa May 1, 2024
083bc61
:sparkles: FEAT. 음성 추가 응답 DTO 추가
junhaa May 1, 2024
1a2dea4
:sparkles: FEAT. 음성 변환 관련 예외 추가
junhaa May 1, 2024
ab35bf9
:recycle: REFACTOR. S3 버킷 경로 및 파일 이름
junhaa May 1, 2024
19695f1
:sparkles: FEAT. MultiPartFile 변환 클래스 추가
junhaa May 1, 2024
1f5343b
:sparkles: FEAT. 음성 변환 서비스 로직 추가
junhaa May 2, 2024
b0a9034
:sparkles: FEAT. 음성 변환 요청 및 Segment Entity 변환 기능 추가
junhaa May 2, 2024
3e80ec3
:sparkles: FEAT. 음성 변환 요청 및 Segment Entity 변환 기능 추가
junhaa May 2, 2024
3778f97
:heavy_plus_sign: ADD. boot-test dependency 추가
junhaa May 2, 2024
88f2ff6
:sparkles: FEAT. 동화 추가 기능 API 요청 및 변환 기능 구현
junhaa May 2, 2024
f784973
:sparkles: FEAT. 동화 추가 기능 API 서비스 로직 구현
junhaa May 2, 2024
274ed4f
:sparkles: FEAT. Elevenlabs 음성 변환 키값 추가 및 키값 변환 기능 추가
junhaa May 2, 2024
b390c4f
:sparkles: FEAT. FairytaleQueryService.java 기본 패키지 구조 작성
junhaa May 2, 2024
3ed05d9
:art: CHORE. 관련 주석 추가
junhaa May 2, 2024
a6fa694
Update gradle.yml
junhaa May 1, 2024
76e6008
:bug: FIX. cors 오류 수정
junhaa May 2, 2024
0bb9e11
:bug: FIX. cors 오류 수정
junhaa May 2, 2024
53001dc
:bug: FIX. cors 오류 수정
junhaa May 2, 2024
8900cad
:bug: FIX. login 응답 오류 해결
May 2, 2024
32da08a
:art: CHORE. Segment.java 코드 포맷팅, 주석 추가
May 2, 2024
8919a56
:bug: FIX. 컨버터 오류 수정
May 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: make application.yml
run: |
mkdir -p src/main/resources
echo "$APPLICATION" > src/main/resources/application.properties
echo "$APPLICATION" > src/main/resources/application.yml
env:
APPLICATION: ${{ secrets.APPLICATION }}

Expand Down
72 changes: 36 additions & 36 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.4'
id 'io.spring.dependency-management' version '1.1.4'
id 'java'
id 'org.springframework.boot' version '3.2.4'
id 'io.spring.dependency-management' version '1.1.4'
}

group = 'fairytale'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '17'
sourceCompatibility = '17'
}

// build 이름 변경
jar{
archiveBaseName = 'fairytale'
version = '0.0.1-SNAPSHOT'
enabled = false
jar {
archiveBaseName = 'fairytale'
version = '0.0.1-SNAPSHOT'
enabled = false
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'

//logging
implementation 'org.springframework.boot:spring-boot-starter-log4j2'
modules {
module("org.springframework.boot:spring-boot-starter-logging") {
replacedBy("org.springframework.boot:spring-boot-starter-log4j2")
}
}
//logging
implementation 'org.springframework.boot:spring-boot-starter-log4j2'
modules {
module("org.springframework.boot:spring-boot-starter-logging") {
replacedBy("org.springframework.boot:spring-boot-starter-log4j2")
}
}

// ElevenLabs API
implementation ('net.andrewcpu:elevenlabs-api:2.7.8')
// ElevenLabs API
implementation('net.andrewcpu:elevenlabs-api:2.7.8')

// AWS
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
// AWS
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'


// Spring Security OAUTH 2.1
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.security:spring-security-oauth2-client'
// Spring Security OAUTH 2.1
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.security:spring-security-oauth2-client'

// JWT token
implementation 'io.jsonwebtoken:jjwt:0.12.3'
// JWT token
implementation 'io.jsonwebtoken:jjwt:0.12.3'

compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
implementation 'org.springframework.boot:spring-boot-starter-test'
}

tasks.named('test') {
useJUnitPlatform()
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package fairytale.tbd.domain.fairytale.converter;

import java.util.ArrayList;

import fairytale.tbd.domain.fairytale.entity.Fairytale;
import fairytale.tbd.domain.fairytale.web.dto.FairytaleRequestDTO;
import fairytale.tbd.domain.fairytale.web.dto.FairytaleResponseDTO;

public class Fairytaleconverter {
public static Fairytale toFairytale(FairytaleRequestDTO.AddFairytaleRequestDTO request) {
return Fairytale.builder()
.name(request.getName())
.segmentList(new ArrayList<>())
.build();
}

public static FairytaleResponseDTO.AddFairytaleResultDTO toAddFairytaleResultDTO(Fairytale fairytale) {
return FairytaleResponseDTO.AddFairytaleResultDTO.builder()
.id(fairytale.getId())
.createdAt(fairytale.getCreatedAt())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package fairytale.tbd.domain.voice.entity;
package fairytale.tbd.domain.fairytale.entity;

import java.util.ArrayList;
import java.util.List;

import fairytale.tbd.domain.voice.entity.Segment;
import fairytale.tbd.global.entity.BaseEntity;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package fairytale.tbd.domain.fairytale.exception;

import fairytale.tbd.global.enums.statuscode.BaseCode;
import fairytale.tbd.global.exception.GeneralException;

public class FairytaleExistExcption extends GeneralException {
public FairytaleExistExcption(BaseCode errorStatus) {
super(errorStatus);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package fairytale.tbd.domain.fairytale.exception;

import fairytale.tbd.global.enums.statuscode.BaseCode;
import fairytale.tbd.global.exception.GeneralException;

public class FairytaleNotFoundException extends GeneralException {
public FairytaleNotFoundException(BaseCode errorStatus) {
super(errorStatus);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package fairytale.tbd.domain.fairytale.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import fairytale.tbd.domain.fairytale.entity.Fairytale;

@Repository
public interface FairytaleRepository extends JpaRepository<Fairytale, Long> {
boolean existsByName(String name);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package fairytale.tbd.domain.fairytale.service;

import fairytale.tbd.domain.fairytale.entity.Fairytale;
import fairytale.tbd.domain.fairytale.web.dto.FairytaleRequestDTO;

public interface FairytaleCommandService {
Fairytale saveFairytale(FairytaleRequestDTO.AddFairytaleRequestDTO request);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package fairytale.tbd.domain.fairytale.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import fairytale.tbd.domain.fairytale.converter.Fairytaleconverter;
import fairytale.tbd.domain.fairytale.entity.Fairytale;
import fairytale.tbd.domain.fairytale.repository.FairytaleRepository;
import fairytale.tbd.domain.fairytale.web.dto.FairytaleRequestDTO;
import fairytale.tbd.global.enums.statuscode.ErrorStatus;
import fairytale.tbd.global.exception.GeneralException;
import lombok.RequiredArgsConstructor;

@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
public class FairytaleCommandServiceImpl implements FairytaleCommandService {
private final FairytaleRepository fairytaleRepository;

@Override
@Transactional
public Fairytale saveFairytale(FairytaleRequestDTO.AddFairytaleRequestDTO request) {
if (fairytaleRepository.existsByName(request.getName())) {
throw new GeneralException(ErrorStatus._FAIRYTALE_EXIST_ERROR);
}
Fairytale fairytale = Fairytaleconverter.toFairytale(request);
return fairytaleRepository.save(fairytale);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package fairytale.tbd.domain.fairytale.service;

public interface FairytaleQueryService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package fairytale.tbd.domain.fairytale.service;

public class FairytaleQueryServiceImpl {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package fairytale.tbd.domain.fairytale.web.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import fairytale.tbd.domain.fairytale.converter.Fairytaleconverter;
import fairytale.tbd.domain.fairytale.entity.Fairytale;
import fairytale.tbd.domain.fairytale.service.FairytaleCommandService;
import fairytale.tbd.domain.fairytale.web.dto.FairytaleRequestDTO;
import fairytale.tbd.domain.fairytale.web.dto.FairytaleResponseDTO;
import fairytale.tbd.global.response.ApiResponse;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/fairytale")
public class FairytaleRestController {
private final FairytaleCommandService fairytaleCommandService;

@PostMapping("")
public ApiResponse<FairytaleResponseDTO.AddFairytaleResultDTO> addFairytale(@Valid @RequestBody
FairytaleRequestDTO.AddFairytaleRequestDTO request) {
Fairytale fairytale = fairytaleCommandService.saveFairytale(request);
return ApiResponse.onSuccess(Fairytaleconverter.toAddFairytaleResultDTO(fairytale));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package fairytale.tbd.domain.fairytale.web.dto;

import jakarta.validation.constraints.NotBlank;
import lombok.Getter;
import lombok.Setter;

public class FairytaleRequestDTO {
@Getter
@Setter
public static class AddFairytaleRequestDTO {
@NotBlank
private String name;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package fairytale.tbd.domain.fairytale.web.dto;

import java.time.LocalDateTime;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

public class FairytaleResponseDTO {
@Builder
@Getter
@NoArgsConstructor
@AllArgsConstructor
public static class AddFairytaleResultDTO {
private Long id;
private LocalDateTime createdAt;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ public class UserCommandServiceImpl implements UserCommandService {
@Transactional
@Override
public User addUser(UserRequestDTO.AddUserDTO request) {
// 비밀번호 암호화
String encodedPassword = passwordEncoder.encode(request.getPassword());
User user = UserConverter.toUser(request, encodedPassword);
// 유저 권한 추가
Authority authority = Authority.builder()
.role(Role.ROLE_USER)
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,44 @@
package fairytale.tbd.domain.voice.converter;

import java.util.ArrayList;

import fairytale.tbd.domain.voice.entity.Segment;
import fairytale.tbd.domain.voice.entity.TTSSegment;
import fairytale.tbd.domain.voice.entity.Voice;
import fairytale.tbd.domain.voice.web.dto.VoiceRequestDTO;
import fairytale.tbd.domain.voice.web.dto.VoiceResponseDTO;

public class VoiceConverter {

public static VoiceResponseDTO.AddVoiceResultDTO toAddVoiceResult(Voice voice){
public static VoiceResponseDTO.AddVoiceResultDTO toAddVoiceResult(Voice voice) {
return VoiceResponseDTO.AddVoiceResultDTO.builder()
.voiceId(voice.getId())
.createdAt(voice.getCreatedAt())
.build();
}

public static Voice toVoice(String keyId){
public static Voice toVoice(String keyId) {
return Voice.builder()
.voiceSampleList(new ArrayList<>())
.keyId(keyId)
.build();
}

public static Segment toSegment(VoiceRequestDTO.AddSegmentDTO request) {
return Segment.builder()
.context(request.getContext())
.isMainCharacter(request.isMainCharacter())
.voiceType(request.getVoiceType())
.num(request.getSegmentNum())
.build();
}

public static VoiceResponseDTO.AddTTSSegmentResultDTO toAddSegmentResultDTO(TTSSegment ttsSegment, Long segmentId) {
return VoiceResponseDTO.AddTTSSegmentResultDTO.builder()
.segmentId(segmentId)
.createdAt(ttsSegment.getCreatedAt())
.ttsSegmentId(ttsSegment.getId())
.url(ttsSegment.getUrl())
.build();
}
}
4 changes: 2 additions & 2 deletions src/main/java/fairytale/tbd/domain/voice/entity/Segment.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package fairytale.tbd.domain.voice.entity;

import fairytale.tbd.domain.fairytale.entity.Fairytale;
import fairytale.tbd.domain.voice.enums.VoiceType;
import fairytale.tbd.global.entity.BaseEntity;
import jakarta.persistence.CascadeType;
Expand Down Expand Up @@ -27,7 +27,7 @@
public class Segment extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "fariytale_segment_id")
@Column(name = "fairytale_segment_id")
private Long id;

@Column(name = "segment_context", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fairytale.tbd.domain.voice.enums;

public enum VoiceType {
OLD_WOMAN, OLD_MAN, YOUNG_WOMAN, YOUNG_MAN;
OLD_WOMAN, OLD_MAN, YOUNG_WOMAN, YOUNG_MAN, NARRATION, MIDDLEAGE_MAN, MIDDLEAGE_WOMAN;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package fairytale.tbd.domain.voice.exception;

import fairytale.tbd.global.enums.statuscode.BaseCode;
import fairytale.tbd.global.exception.GeneralException;

public class InvalidVoiceTypeException extends GeneralException {
public InvalidVoiceTypeException(BaseCode errorStatus) {
super(errorStatus);
}
}
Loading
Loading