Skip to content

Commit

Permalink
feat : fetch meal deliveries by orderId
Browse files Browse the repository at this point in the history
  • Loading branch information
JiwonKKang committed Sep 24, 2024
1 parent 811bb95 commit fda8359
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package core.startup.mealtoktok.api.mealdelivery;

import java.util.List;

import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
Expand Down Expand Up @@ -49,6 +51,15 @@ public Response<SliceResult<MealDeliveryResponse>> searchMealDeliveries(
.map(MealDeliveryResponse::from));
}

@GetMapping("/order")
public Response<List<MealDeliveryResponse>> getMealDeliveriesByOrderId(String orderId) {
List<MealDeliveryResponse> responses =
mealDeliveryService.getMealDeliveries(OrderId.from(orderId)).stream()
.map(MealDeliveryResponse::from)
.toList();
return Response.success(responses);
}

@GetMapping("/{mealDeliveryId}")
public Response<MealDeliveryResponse> mealDelivery(@PathVariable Long mealDeliveryId) {
return Response.success(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package core.startup.mealtoktok.api.mealdelivery;

import java.util.List;

import org.springframework.security.core.annotation.AuthenticationPrincipal;

import core.startup.mealtoktok.api.global.dto.Response;
Expand All @@ -23,6 +25,9 @@ public interface MealDeliveryApiDocs {
Response<SliceResult<MealDeliveryResponse>> searchMealDeliveries(
User currentUser, MealDeliverySearchCond cond, Cursor cursor);

@Operation(summary = "주문에 포함된 도시락 배송 목록 조회")
Response<List<MealDeliveryResponse>> getMealDeliveriesByOrderId(String orderId);

@Operation(summary = "도시락 배송 단건 조회")
Response<MealDeliveryResponse> mealDelivery(Long mealDeliveryId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public SliceResult<MealDelivery> searchMealDeliveries(
return mealDeliveryReader.read(recipient, cond, cursor);
}

public List<MealDelivery> getMealDeliveries(OrderId orderId) {
return mealDeliveryReader.read(orderId);
}

public MealDelivery getNextDeliveryMeal(OrderId orderId) {
List<MealDelivery> mealDeliveries = mealDeliveryReader.read(orderId);
return mealDeliveries.stream()
Expand Down

0 comments on commit fda8359

Please sign in to comment.