-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Server] feat : 레시피 조회시, 메인 재료 여부를 확인할 수 있습니다. (#61)
* refactor(ContainerIngredientDto) : 불필요한 import 제거 * feat(IngredientMatcher) : 해당 재료가 레시피의 메인 재료인지 확인할 수 있다 - IngredientDto 수정 - Recipe와 IngredientDtos를 넘겨 해당 레시피의 메인 재료일시, 명시한다. - Dto는 최상위 Dto에 바로 매개변수로 넣어 만들기보다는 차근차근 만들어 나갑니다. - 레시피 메인재료 데이터에 접근하는 Repository 생성 * chore(SwaggerConfig) : 로컬호스트를 테스트 서버로 추가 * style(Dockerfile) : 불필요한 주석 및 개행 제거
- Loading branch information
Showing
9 changed files
with
100 additions
and
48 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
3 changes: 0 additions & 3 deletions
3
...o/src/main/java/com/sundaegukbap/banchango/ingredient/dto/dto/ContainerIngredientDto.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
33 changes: 22 additions & 11 deletions
33
.../banchango/src/main/java/com/sundaegukbap/banchango/ingredient/dto/dto/IngredientDto.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,19 +1,30 @@ | ||
package com.sundaegukbap.banchango.ingredient.dto.dto; | ||
|
||
import com.sundaegukbap.banchango.ingredient.domain.Ingredient; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
public record IngredientDto( | ||
Long id, | ||
String name, | ||
String kind, | ||
String image | ||
) { | ||
public static IngredientDto of(Ingredient ingredient){ | ||
@AllArgsConstructor | ||
@Getter | ||
public class IngredientDto { | ||
|
||
private Long id; | ||
private String name; | ||
private String kind; | ||
private String image; | ||
private boolean isMain; | ||
|
||
public static IngredientDto of(Ingredient ingredient) { | ||
return new IngredientDto( | ||
ingredient.getId(), | ||
ingredient.getName(), | ||
ingredient.getKind(), | ||
ingredient.getImage() | ||
ingredient.getId(), | ||
ingredient.getName(), | ||
ingredient.getKind(), | ||
ingredient.getImage(), | ||
false | ||
); | ||
} | ||
|
||
public void setIsMain(boolean isMain) { | ||
this.isMain = isMain; | ||
} | ||
} |
9 changes: 2 additions & 7 deletions
9
...banchango/src/main/java/com/sundaegukbap/banchango/ingredient/dto/dto/IngredientDtos.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,16 +1,11 @@ | ||
package com.sundaegukbap.banchango.ingredient.dto.dto; | ||
|
||
import com.sundaegukbap.banchango.ingredient.domain.Ingredient; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public record IngredientDtos( | ||
List<IngredientDto> ingredientDtos | ||
) { | ||
public static IngredientDtos of(List<Ingredient> ingredientList){ | ||
return new IngredientDtos(ingredientList.stream() | ||
.map(IngredientDto::of) | ||
.collect(Collectors.toList())); | ||
public static IngredientDtos of(List<IngredientDto> ingredientDtos){ | ||
return new IngredientDtos(ingredientDtos); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...java/com/sundaegukbap/banchango/ingredient/repository/RecipeMainIngredientRepository.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,14 @@ | ||
package com.sundaegukbap.banchango.ingredient.repository; | ||
|
||
import com.sundaegukbap.banchango.ingredient.domain.RecipeMainIngredient; | ||
import com.sundaegukbap.banchango.recipe.domain.Recipe; | ||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface RecipeMainIngredientRepository extends JpaRepository<RecipeMainIngredient, Long> { | ||
|
||
List<RecipeMainIngredient> findByRecipe(Recipe recipe); | ||
|
||
} |
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: 8 additions & 9 deletions
17
...c/main/java/com/sundaegukbap/banchango/recipe/dto/response/RecommendedRecipeResponse.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,21 +1,20 @@ | ||
package com.sundaegukbap.banchango.recipe.dto.response; | ||
|
||
import com.sundaegukbap.banchango.ingredient.domain.Ingredient; | ||
import com.sundaegukbap.banchango.ingredient.dto.dto.IngredientDtos; | ||
import com.sundaegukbap.banchango.recipe.domain.Recipe; | ||
import com.sundaegukbap.banchango.recipe.dto.dto.RecipeDto; | ||
|
||
import java.util.List; | ||
|
||
public record RecommendedRecipeResponse( | ||
RecipeDto recipe, | ||
IngredientDtos have, | ||
RecipeDto recipe, | ||
IngredientDtos have, | ||
IngredientDtos need) { | ||
|
||
public static RecommendedRecipeResponse of(Recipe recipe, IngredientDtos have, | ||
IngredientDtos need) { | ||
public static RecommendedRecipeResponse of(Recipe recipe, List<Ingredient> have, List<Ingredient> need){ | ||
return new RecommendedRecipeResponse( | ||
RecipeDto.of(recipe), | ||
IngredientDtos.of(have), | ||
IngredientDtos.of(need) | ||
RecipeDto.of(recipe), | ||
have, | ||
need | ||
); | ||
} | ||
} |