Skip to content

Commit

Permalink
feat: 메뉴 당 옵션 조회 api 기능 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
summit45 committed Nov 15, 2023
1 parent 8adc926 commit 6c8da41
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/com/kusitms/jipbap/food/FoodController.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ public CommonResponse<FoodDetailResponse> getFoodDetail(@PathVariable Long foodI
return new CommonResponse<>(foodService.getFoodDetail(foodId));
}

@Operation(summary = "메뉴 당 옵션 상세조회")
@GetMapping("/{foodId}/option")
@ResponseStatus(HttpStatus.OK)
public CommonResponse<List<FoodOptionResponse>> getFoodDetailByOption(@PathVariable Long foodId ) {
return new CommonResponse<>(foodService.getFoodDetailByOption(foodId));
}

@Operation(summary = "홈에서 현재 지역 내에서 인기메뉴 조회하기")
@GetMapping("/home")
@ResponseStatus(HttpStatus.OK)
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/kusitms/jipbap/food/FoodService.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ public FoodDetailResponse getFoodDetail(Long foodId) {
return new FoodDetailResponse(food.getId(), food.getStore().getId(), food.getCategory().getId(), food.getName(), food.getDollarPrice(), food.getCanadaPrice(), food.getDescription(), food.getImage(), foodOptionResponseList);
}

public List<FoodOptionResponse> getFoodDetailByOption(Long foodId) {
Food food = foodRepository.findById(foodId).orElseThrow(()-> new FoodNotExistsException("해당 음식 Id는 유효하지 않습니다."));
List<FoodOptionResponse> foodOptionResponseList = foodOptionRepository.findAllByFood(food).stream()
.map(foodOption -> new FoodOptionResponse(foodOption.getId(), foodOption.getName(), foodOption.getDollarPrice(), foodOption.getCanadaPrice()))
.collect(Collectors.toList());
return foodOptionResponseList;
}

public List<BestSellingFoodResponse> getBestSellingFoodByRegion(String email) {
User user = userRepository.findByEmail(email).orElseThrow(()-> new UserNotFoundException("유저 정보가 존재하지 않습니다."));

Expand Down

0 comments on commit 6c8da41

Please sign in to comment.