Skip to content

Commit eb82c9e

Browse files
authored
Merge pull request #85 from username056/feat-recipe
[feat] 퍼블릭 레시피 조회 API 응답 RecipeDto 리스트로 변경
2 parents b2087e4 + 57649d5 commit eb82c9e

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

yechef/src/main/java/sejong/capston/yechef/domain/Recipe/controller/RecipeController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public ResponseEntity<Void> deleteRecipe(
6969

7070
// 공개 목록 조회
7171
@GetMapping("/public")
72-
public ResponseEntity<List<Recipe>> getPublicRecipes() {
72+
public ResponseEntity<List<RecipeDto>> getPublicRecipes() {
7373
return ResponseEntity.ok(recipeService.getPublicRecipes());
7474
}
7575
}

yechef/src/main/java/sejong/capston/yechef/domain/Recipe/dto/RecipeDto.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class RecipeDto {
1313
private String title;
1414
private String author;
1515
private Recipe.RecipeType recipeType;
16+
private String text;
1617
private int likeCount;
1718
private String thumbnailImageUrl;
1819
private String sourceImageUrl;
@@ -25,6 +26,7 @@ public static RecipeDto from(Recipe recipe) {
2526
.author(recipe.getAuthor())
2627
.recipeType(recipe.getRecipeType())
2728
.likeCount(recipe.getLikeCount())
29+
.text(recipe.getText())
2830
.thumbnailImageUrl(recipe.getThumbnailImage() != null ? recipe.getThumbnailImage().getS3Url() : null)
2931
.sourceImageUrl(recipe.getSourceImage() != null ? recipe.getSourceImage().getS3Url() : null)
3032
.build();

yechef/src/main/java/sejong/capston/yechef/domain/Recipe/service/RecipeService.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,12 @@ public List<RecipeDto> getLikedRecipes(Long memberId) {
137137
return likedRecipes.stream().map(RecipeDto::from).collect(Collectors.toList());
138138
}
139139

140-
public List<Recipe> getPublicRecipes() {
141-
return recipeRepository.findByRecipeType(Recipe.RecipeType.PUBLIC);
140+
public List<RecipeDto> getPublicRecipes() {
141+
return recipeRepository
142+
.findByRecipeType(Recipe.RecipeType.PUBLIC)
143+
.stream()
144+
.map(RecipeDto::from)
145+
.collect(Collectors.toList());
142146
}
143147

144148
@Transactional(readOnly = true)

0 commit comments

Comments
 (0)