diff --git a/warehouse/src/main/java/warehouse/domain/shipping/business/ShippingBusiness.java b/warehouse/src/main/java/warehouse/domain/shipping/business/ShippingBusiness.java index 562efde6..048f7705 100644 --- a/warehouse/src/main/java/warehouse/domain/shipping/business/ShippingBusiness.java +++ b/warehouse/src/main/java/warehouse/domain/shipping/business/ShippingBusiness.java @@ -13,11 +13,11 @@ import warehouse.domain.goods.service.GoodsService; import warehouse.domain.image.controller.model.ImageListResponse; import warehouse.domain.image.converter.ImageConverter; +import warehouse.domain.image.service.ImageService; import warehouse.domain.shipping.controller.model.request.ShippingRequest; import warehouse.domain.shipping.controller.model.response.MessageResponse; -import warehouse.domain.shipping.controller.model.response.ShippingDetailResponse; import warehouse.domain.shipping.controller.model.response.ShippingListResponse; -import warehouse.domain.shipping.controller.model.response.ShippingResponse; +import warehouse.domain.shipping.controller.model.response.ShippingDetailResponse; import warehouse.domain.shipping.controller.model.response.ShippingStatusResponse; import warehouse.domain.shipping.converter.ShippingConverter; import warehouse.domain.shipping.service.ShippingService; @@ -49,14 +49,23 @@ public MessageResponse shippingRequest(ShippingRequest request, String email) { public ShippingListResponse getShippingList(String email) { Long userId = getUserWithThrow(email).getId(); - List shippingEntityList = shippingService.getShippingList(userId); - List shippingDetailResponseList = shippingEntityList.stream().map(shippingEntity -> { - return getShippingDetail(shippingEntity.getId()); + List shippingResponse = shippingEntityList.stream().map(shippingEntity -> { + List goodsEntityList = goodsService.findAllByShippingIdWithThrow( + shippingEntity.getId()); + + List goodsResponseList = goodsEntityList.stream() + .map(goodsEntity -> { + ImageListResponse imageListResponse = imageConverter.toImageListResponse( + goodsEntity); + return goodsConverter.toResponse(goodsEntity, imageListResponse); + }).toList(); + + return shippingConverter.toResponse(shippingEntity, goodsResponseList); }).toList(); - return shippingConverter.toResponseList(shippingDetailResponseList); + return shippingConverter.toResponse(shippingResponse); } public ShippingDetailResponse getShippingDetail(Long shippingId) { @@ -71,9 +80,7 @@ public ShippingDetailResponse getShippingDetail(Long shippingId) { return goodsConverter.toResponse(goodsEntity, imageListResponse); }).toList(); - ShippingResponse shippingResponse = shippingConverter.toResponse(shippingEntity); - - return shippingConverter.toResponse(shippingResponse, goodsResponseList); + return shippingConverter.toResponse(shippingEntity, goodsResponseList); } public ShippingStatusResponse getCurrentStatusBy(Long shippingId) { diff --git a/warehouse/src/main/java/warehouse/domain/shipping/controller/ShippingApiController.java b/warehouse/src/main/java/warehouse/domain/shipping/controller/ShippingApiController.java index 167f1c0e..beabf5d6 100644 --- a/warehouse/src/main/java/warehouse/domain/shipping/controller/ShippingApiController.java +++ b/warehouse/src/main/java/warehouse/domain/shipping/controller/ShippingApiController.java @@ -14,9 +14,9 @@ import org.springframework.web.bind.annotation.RestController; import warehouse.domain.shipping.business.ShippingBusiness; import warehouse.domain.shipping.controller.model.request.ShippingRequest; -import warehouse.domain.shipping.controller.model.response.ShippingDetailResponse; import warehouse.domain.shipping.controller.model.response.ShippingListResponse; import warehouse.domain.shipping.controller.model.response.MessageResponse; +import warehouse.domain.shipping.controller.model.response.ShippingDetailResponse; import warehouse.domain.shipping.controller.model.response.ShippingStatusResponse; @RestController @@ -38,7 +38,8 @@ public Api shippingRequest(@AuthenticationPrincipal User user, @GetMapping() //목록조회 @Operation(summary = "[출고 요청서 목록 보기]") public Api getShippingList(@AuthenticationPrincipal User user) { - ShippingListResponse response = shippingBusiness.getShippingList(user.getUsername()); + ShippingListResponse response = shippingBusiness.getShippingList( + user.getUsername()); return Api.OK(response); } diff --git a/warehouse/src/main/java/warehouse/domain/shipping/controller/model/response/ShippingDetailResponse.java b/warehouse/src/main/java/warehouse/domain/shipping/controller/model/response/ShippingDetailResponse.java index ddfa5b5b..b428bda0 100644 --- a/warehouse/src/main/java/warehouse/domain/shipping/controller/model/response/ShippingDetailResponse.java +++ b/warehouse/src/main/java/warehouse/domain/shipping/controller/model/response/ShippingDetailResponse.java @@ -1,5 +1,7 @@ package warehouse.domain.shipping.controller.model.response; +import db.domain.shipping.enums.ShippingStatus; +import java.time.LocalDateTime; import java.util.List; import lombok.AllArgsConstructor; import lombok.Builder; @@ -13,7 +15,15 @@ @Builder public class ShippingDetailResponse { - private ShippingResponse shipping; - private List goods; + private Long shippingId; + + private LocalDateTime deliveryDate; + + private String deliveryAddress; + private ShippingStatus status; + + private Long deliveryMan; + + private List goods; } diff --git a/warehouse/src/main/java/warehouse/domain/shipping/controller/model/response/ShippingListResponse.java b/warehouse/src/main/java/warehouse/domain/shipping/controller/model/response/ShippingListResponse.java index 0acb6ad8..451241e1 100644 --- a/warehouse/src/main/java/warehouse/domain/shipping/controller/model/response/ShippingListResponse.java +++ b/warehouse/src/main/java/warehouse/domain/shipping/controller/model/response/ShippingListResponse.java @@ -11,5 +11,8 @@ @AllArgsConstructor @Builder public class ShippingListResponse { - List shipping; + + private List shippingList; + } + diff --git a/warehouse/src/main/java/warehouse/domain/shipping/controller/model/response/ShippingResponse.java b/warehouse/src/main/java/warehouse/domain/shipping/controller/model/response/ShippingResponse.java deleted file mode 100644 index 9ece259f..00000000 --- a/warehouse/src/main/java/warehouse/domain/shipping/controller/model/response/ShippingResponse.java +++ /dev/null @@ -1,26 +0,0 @@ -package warehouse.domain.shipping.controller.model.response; - -import db.domain.shipping.enums.ShippingStatus; -import java.time.LocalDateTime; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class ShippingResponse { - - private Long shippingId; - - private LocalDateTime deliveryDate; - - private String deliveryAddress; - - private ShippingStatus status; - - private Long deliveryMan; - -} diff --git a/warehouse/src/main/java/warehouse/domain/shipping/converter/ShippingConverter.java b/warehouse/src/main/java/warehouse/domain/shipping/converter/ShippingConverter.java index 0eaf94e2..a9143dc4 100644 --- a/warehouse/src/main/java/warehouse/domain/shipping/converter/ShippingConverter.java +++ b/warehouse/src/main/java/warehouse/domain/shipping/converter/ShippingConverter.java @@ -5,13 +5,11 @@ import global.annotation.Converter; import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; import warehouse.domain.goods.controller.model.GoodsResponse; import warehouse.domain.shipping.controller.model.request.ShippingRequest; import warehouse.domain.shipping.controller.model.response.MessageResponse; -import warehouse.domain.shipping.controller.model.response.ShippingDetailResponse; import warehouse.domain.shipping.controller.model.response.ShippingListResponse; -import warehouse.domain.shipping.controller.model.response.ShippingResponse; +import warehouse.domain.shipping.controller.model.response.ShippingDetailResponse; import warehouse.domain.shipping.controller.model.response.ShippingStatusResponse; @Converter @@ -31,26 +29,19 @@ public MessageResponse toMessageResponse(String message) { .build(); } - public ShippingListResponse toResponseList(List shippingDetailResponseList) { + public ShippingListResponse toResponse(List shippingResponses) { return ShippingListResponse.builder() - .shipping(shippingDetailResponseList) + .shippingList(shippingResponses) .build(); } - public ShippingResponse toResponse(ShippingEntity entity) { - return ShippingResponse.builder() + public ShippingDetailResponse toResponse(ShippingEntity entity, List goodsResponses) { + return ShippingDetailResponse.builder() .shippingId(entity.getId()) .deliveryDate(entity.getDeliveryDate()) .deliveryAddress(entity.getDeliveryAddress()) .status(entity.getStatus()) .deliveryMan(entity.getDeliveryMan()) - .build(); - } - - public ShippingDetailResponse toResponse(ShippingResponse shippingResponse, - List goodsResponses) { - return ShippingDetailResponse.builder() - .shipping(shippingResponse) .goods(goodsResponses) .build(); }