-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor: 스케줄링 허용 * Feat: Language 클래스 생성 * Feat: Conversation 생성 - 오늘의 회화 - 영어, 일본어, 스페인어, 프랑스어 * Feat: 오늘의 회화 업데이트 * Delete: 테스트용 Controller 코드 삭제 * Refactor: language 반환 제거 * Refactor: ManyToOne으로 수정
- Loading branch information
1 parent
6fce5d0
commit 1c56f21
Showing
15 changed files
with
281 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/java/com/example/tripy/domain/conversation/ConversationController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,25 @@ | ||
package com.example.tripy.domain.conversation; | ||
|
||
import com.example.tripy.domain.conversation.dto.ConversationResponseDto.ConversationDetailResponse; | ||
import com.example.tripy.global.s3.S3Service; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
public class ConversationController { | ||
|
||
private final ConversationService conversationService; | ||
private final S3Service s3Service; | ||
|
||
@GetMapping("/api/conversation/country/{country-id}") | ||
public ResponseEntity<List<ConversationDetailResponse>> findConversationListByCountry( | ||
@PathVariable("country-id") Long countryId) { | ||
return ResponseEntity.ok(conversationService.findConversationListByCountry(countryId)); | ||
} | ||
|
||
} |
2 changes: 2 additions & 0 deletions
2
src/main/java/com/example/tripy/domain/conversation/ConversationRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package com.example.tripy.domain.conversation; | ||
|
||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface ConversationRepository extends JpaRepository<Conversation, Long> { | ||
List<Conversation> findAllByCountryId(Long countryId); | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/example/tripy/domain/conversation/ConversationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
package com.example.tripy.domain.conversation; | ||
|
||
import com.example.tripy.domain.conversation.dto.ConversationResponseDto.ConversationDetailResponse; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@RequiredArgsConstructor | ||
@Service | ||
public class ConversationService { | ||
private final ConversationRepository conversationRepository; | ||
|
||
public List<ConversationDetailResponse> findConversationListByCountry(Long countryId) { | ||
return conversationRepository.findAllByCountryId(countryId) | ||
.stream() | ||
.map(ConversationDetailResponse::toDTO) | ||
.toList(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/example/tripy/domain/conversation/dto/ConversationRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.example.tripy.domain.conversation.dto; | ||
|
||
import com.example.tripy.domain.country.Country; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
public class ConversationRequestDto { | ||
@Getter | ||
@AllArgsConstructor | ||
public static class ConversationCreateRequest { | ||
private String korean; | ||
|
||
private String translation; | ||
|
||
private String pronunciation; | ||
|
||
private Country country; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/example/tripy/domain/conversation/dto/ConversationResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.example.tripy.domain.conversation.dto; | ||
|
||
import com.example.tripy.domain.conversation.Conversation; | ||
import com.example.tripy.domain.language.Language; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
public class ConversationResponseDto { | ||
|
||
@Builder | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class ConversationDetailResponse { | ||
|
||
private String koreanSentences; | ||
private String translatedSentences; | ||
private Long countryId; | ||
private String pronunciation; | ||
|
||
public static ConversationDetailResponse toDTO(Conversation conversation) { | ||
return ConversationDetailResponse.builder() | ||
.koreanSentences(conversation.getKorean()) | ||
.translatedSentences(conversation.getTranslation()) | ||
.countryId(conversation.getCountry().getId()) | ||
.pronunciation(conversation.getPronunciation()) | ||
.build(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/com/example/tripy/domain/language/Language.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.example.tripy.domain.language; | ||
|
||
import com.example.tripy.global.utils.BaseTimeEntity; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Entity | ||
public class Language extends BaseTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@NotNull | ||
private String languageName; | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/example/tripy/domain/language/LanguageController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.example.tripy.domain.language; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
public class LanguageController { | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/example/tripy/domain/language/LanguageRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.example.tripy.domain.language; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface LanguageRepository extends JpaRepository<Language, Long> { | ||
Language findByLanguageName(String languageName); | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/example/tripy/domain/language/LanguageService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.example.tripy.domain.language; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@RequiredArgsConstructor | ||
@Service | ||
public class LanguageService { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.