File tree Expand file tree Collapse file tree 2 files changed +23
-13
lines changed
src/main/java/com/back/domain/cocktail Expand file tree Collapse file tree 2 files changed +23
-13
lines changed Original file line number Diff line number Diff line change 11package com .back .domain .cocktail .dto ;
22
3+ import com .back .domain .cocktail .entity .Cocktail ;
34import com .back .domain .cocktail .service .CocktailService ;
45
56import java .util .List ;
@@ -14,6 +15,26 @@ public record CocktailDetailResponseDto(
1415 String cocktailImgUrl ,
1516 String cocktailStory ,
1617 List <CocktailService .IngredientDto > ingredient ,
17- String recipe
18+ String recipe ,
19+ String cocktailPreview
1820) {
21+ public static CocktailDetailResponseDto from (Cocktail cocktail , List <CocktailService .IngredientDto > ingredients ){
22+ String preview =cocktail .getCocktailStory ().length () >80 ?
23+ cocktail .getCocktailStory ().substring (0 ,80 )+"..."
24+ : cocktail .getCocktailStory ();
25+
26+ return new CocktailDetailResponseDto (
27+ cocktail .getId (),
28+ cocktail .getCocktailName (),
29+ cocktail .getCocktailNameKo (),
30+ cocktail .getAlcoholStrength ().getDescription (),
31+ cocktail .getCocktailType ().getDescription (),
32+ cocktail .getAlcoholBaseType ().getDescription (),
33+ cocktail .getCocktailImgUrl (),
34+ cocktail .getCocktailStory (),
35+ ingredients ,
36+ cocktail .getRecipe (),
37+ preview
38+ );
39+ }
1940}
Original file line number Diff line number Diff line change @@ -124,18 +124,7 @@ public CocktailDetailResponseDto getCocktailDetailById(Long cocktailId) {
124124 // ingredient 분수 변환
125125 List <IngredientDto > formattedIngredient = parseIngredients (convertFractions (cocktail .getIngredient ()));
126126
127- return new CocktailDetailResponseDto (
128- cocktail .getId (),
129- cocktail .getCocktailName (),
130- cocktail .getCocktailNameKo (),
131- cocktail .getAlcoholStrength ().getDescription (),
132- cocktail .getCocktailType ().getDescription (),
133- cocktail .getAlcoholBaseType ().getDescription (),
134- cocktail .getCocktailImgUrl (),
135- cocktail .getCocktailStory (),
136- formattedIngredient ,
137- cocktail .getRecipe ()
138- );
127+ return CocktailDetailResponseDto .from (cocktail , formattedIngredient );
139128 }
140129
141130 private String convertFractions (String ingredient ) {
You can’t perform that action at this time.
0 commit comments