Skip to content

Commit

Permalink
fix(AiRecipeRecommendClient) : 카테고리 정보 추가
Browse files Browse the repository at this point in the history
- 특정 카테고리를 지정하여 레시피 추천을 받을 수 있습니다.
- ai 서버의 주소가 변경되었으므로, 이를 반영합니다.
  • Loading branch information
Due-IT committed Nov 17, 2024
1 parent 0a35bad commit 26858e6
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public AiRecipeRecommendClient(RestTemplate restTemplate) {

@Transactional
public List<Long> getRecommendedRecipesFromAI(RecipeCategory category, List<Ingredient> ingredientList) {
AiRecipeRecommendRequest request = AiRecipeRecommendRequest.of(ingredientList);
AiRecipeRecommendResponse response = restTemplate.postForObject(aiBaseUrl + "/recommend", request, AiRecipeRecommendResponse.class);
AiRecipeRecommendRequest request = AiRecipeRecommendRequest.of(category, ingredientList);
AiRecipeRecommendResponse response = restTemplate.postForObject(aiBaseUrl + "/category_recommend", request, AiRecipeRecommendResponse.class);

return response.recommended_recipes();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@

import com.sundaegukbap.banchango.ingredient.domain.Ingredient;

import com.sundaegukbap.banchango.recipe.domain.RecipeCategory;
import java.util.List;
import java.util.stream.Collectors;

public record AiRecipeRecommendRequest(
List<Long> ingredients
List<Long> ingredients,
int topcategory,
String subcategory
) {
public static AiRecipeRecommendRequest of(List<Ingredient> ingredients) {
public static AiRecipeRecommendRequest of(RecipeCategory recipeCategory, List<Ingredient> ingredients) {
List<Long> ingredientIds = ingredients.stream()
.map(Ingredient::getId)
.collect(Collectors.toList());

return new AiRecipeRecommendRequest(ingredientIds);
return new AiRecipeRecommendRequest(ingredientIds, recipeCategory.getTopCategory(), recipeCategory.getSubCategory());
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,50 @@
package com.sundaegukbap.banchango.recipe.domain;

public enum RecipeCategory {
전체,
간식,
기타,
다이어트,
도시락,
명절,
손님접대,
술안주,
야식,
이유식,
일상,
초스피드,
푸드스타일링,
해장
전체(0, "전체"),
밑반찬(1, "밑반찬"),
메인반찬(1, "메인반찬"),
국_탕(1, "국/탕"),
찌개(1, "찌개"),
디저트(1, "디저트"),
면_만두(1, "면/만두"),
밥_죽_떡(1, "밥/죽/떡"),
퓨전(1, "퓨전"),
김치_젓갈_장류(1, "김치/젓갈/장류"),
양념_소스_잼(1, "양념/소스/잼"),
양식(1, "양식"),
샐러드(1, "샐러드"),
스프(1, "스프"),
빵_과자(1, "빵/과자"),
과자_간식(1, "과자/간식"),
차_음료_술(1, "차/음료/술"),
일상(2, "일상"),
초스피드(2, "초스피드"),
손님접대(2, "손님접대"),
술안주(2, "술안주"),
다이어트(2, "다이어트"),
도시락(2, "도시락"),
영양식(2, "영양식"),
간식(2, "간식"),
야식(2, "야식"),
푸드스타일링(2, "푸드스타일링"),
해장(2, "해장"),
명절음식(2, "명절음식"),
이유식(2, "이유식");

private final int topCategory;
private final String subCategory;

RecipeCategory(int topCategory, String subCategory) {
this.topCategory = topCategory;
this.subCategory = subCategory;
}

public int getTopCategory() {
return topCategory;
}

public String getSubCategory() {
return subCategory;
}
}
2 changes: 1 addition & 1 deletion Server/banchango/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ spring.profiles.active=prod
app.cors.allowedOrigins=https://backendu.com,http://34.222.135.30:8000,http://localhost:3000,http://localhost:8080
app.oauth2.authorizedRedirectUris=https://backendu.com,http://34.222.135.30:8000,http://localhost:3000/oauth2/redirect,myandroidapp://oauth2/redirect,myiosapp://oauth2/redirect

api.aiBaseUrl=http://34.222.135.30:8000
api.aiBaseUrl=http://44.242.23.64:8000

0 comments on commit 26858e6

Please sign in to comment.