-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Refactor: RecipeResponse
- Loading branch information
Showing
6 changed files
with
80 additions
and
12 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
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
49 changes: 49 additions & 0 deletions
49
src/main/java/com/kim3ho1/yourprotein/dto/RecipeResponseDto.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,49 @@ | ||
package com.kim3ho1.yourprotein.dto; | ||
|
||
import java.util.List; | ||
|
||
import com.kim3ho1.yourprotein.domain.Recipe; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
public class RecipeResponseDto { | ||
@Data | ||
@AllArgsConstructor | ||
@Builder | ||
public static class RecipeDetailResponseDto { | ||
private Long id; | ||
|
||
private String recipeName; | ||
private String details; // 재료 | ||
private String kcal; | ||
private String carbo; | ||
private double protein; | ||
private String fat; | ||
private String na; | ||
private String kind; // 요리 종류 | ||
private List<String> images; | ||
|
||
private List<String> manual; | ||
|
||
} | ||
public static RecipeDetailResponseDto from(Recipe recipe) { | ||
return RecipeResponseDto.RecipeDetailResponseDto.builder() | ||
.id(recipe.getId()) | ||
.recipeName(recipe.getRecipeName()) | ||
.details(recipe.getDetails()) | ||
.kcal(recipe.getKcal()) | ||
.carbo(recipe.getCarbo()) | ||
.protein(recipe.getProtein()) | ||
.fat(recipe.getFat()) | ||
.na(recipe.getNa()) | ||
.kind(recipe.getKind()) | ||
.images(List.of(recipe.getImages().split("\n"))) | ||
.manual(List.of(recipe.getManual().split("\n"))).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