Skip to content

Commit

Permalink
SB-235 (refactor) : 출고 요청서 목록 & 상세 보기 응답 형식 변경
Browse files Browse the repository at this point in the history
SB-235 (refactor) : 출고 요청서 목록 & 상세 보기 응답 형식 변경

1. ShippinResponse 제거 -> ShippingDetailResponse 로 대체
2. ShippingListResponse
- List<ShippingDetailResponse> 로 변경
3. ShippingApiController
- 요청서 목록 조회 반환 형식 변경
4. ShippingConverter
- 사용하지 않는 `toResponse` 메서드 제거
5. ShippingBusiness
- 목록 보기 & 상세 보기 로직 및 반환값 변경
  • Loading branch information
seob7 committed Aug 2, 2024
1 parent f2f3477 commit f931c1b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
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;
Expand All @@ -34,7 +33,6 @@ public class ShippingBusiness {
private final ShippingConverter shippingConverter;
private final ImageConverter imageConverter;
private final GoodsConverter goodsConverter;
private final ImageService imageService;

@Transactional
public MessageResponse shippingRequest(ShippingRequest request, String email) {
Expand All @@ -49,11 +47,11 @@ public MessageResponse shippingRequest(ShippingRequest request, String email) {
return shippingConverter.toMessageResponse("출고 신청이 완료되었습니다.");
}

public List<ShippingListResponse> getShippingList(String email) {
public ShippingListResponse getShippingList(String email) {
Long userId = getUserWithThrow(email).getId();
List<ShippingEntity> shippingEntityList = shippingService.getShippingList(userId);

return shippingEntityList.stream().map(shippingEntity -> {
List<ShippingDetailResponse> shippingResponse = shippingEntityList.stream().map(shippingEntity -> {
List<GoodsEntity> goodsEntityList = goodsService.findAllByShippingIdWithThrow(
shippingEntity.getId());

Expand All @@ -66,6 +64,8 @@ public List<ShippingListResponse> getShippingList(String email) {

return shippingConverter.toResponse(shippingEntity, goodsResponseList);
}).toList();

return shippingConverter.toResponse(shippingResponse);
}

public ShippingDetailResponse getShippingDetail(Long shippingId) {
Expand All @@ -80,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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import global.annotation.ApiValid;
import global.api.Api;
import io.swagger.v3.oas.annotations.Operation;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.User;
Expand All @@ -15,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
Expand All @@ -38,8 +37,8 @@ public Api<MessageResponse> shippingRequest(@AuthenticationPrincipal User user,

@GetMapping() //목록조회
@Operation(summary = "[출고 요청서 목록 보기]")
public Api<List<ShippingListResponse>> getShippingList(@AuthenticationPrincipal User user) {
List<ShippingListResponse> response = shippingBusiness.getShippingList(
public Api<ShippingListResponse> getShippingList(@AuthenticationPrincipal User user) {
ShippingListResponse response = shippingBusiness.getShippingList(
user.getUsername());
return Api.OK(response);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -13,7 +15,15 @@
@Builder
public class ShippingDetailResponse {

private ShippingResponse shipping;
private List<GoodsResponse> goods;
private Long shippingId;

private LocalDateTime deliveryDate;

private String deliveryAddress;

private ShippingStatus status;

private Long deliveryMan;

private List<GoodsResponse> goods;
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
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;
import lombok.Data;
import lombok.NoArgsConstructor;
import warehouse.domain.goods.controller.model.GoodsResponse;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ShippingListResponse {

private Long shippingId;
private List<ShippingDetailResponse> shippingList;

private LocalDateTime deliveryDate;

private String deliveryAddress;

private ShippingStatus status;

private Long deliveryMan;

private List<GoodsResponse> goods;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,31 +29,19 @@ public MessageResponse toMessageResponse(String message) {
.build();
}

public ShippingListResponse toResponse(ShippingEntity entity, List<GoodsResponse> goodsResponses) {
public ShippingListResponse toResponse(List<ShippingDetailResponse> shippingResponses) {
return ShippingListResponse.builder()
.shippingId(entity.getId())
.deliveryDate(entity.getDeliveryDate())
.deliveryAddress(entity.getDeliveryAddress())
.status(entity.getStatus())
.deliveryMan(entity.getDeliveryMan())
.goods(goodsResponses)
.shippingList(shippingResponses)
.build();
}

public ShippingResponse toResponse(ShippingEntity entity) {
return ShippingResponse.builder()
public ShippingDetailResponse toResponse(ShippingEntity entity, List<GoodsResponse> 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<GoodsResponse> goodsResponses) {
return ShippingDetailResponse.builder()
.shipping(shippingResponse)
.goods(goodsResponses)
.build();
}
Expand Down

0 comments on commit f931c1b

Please sign in to comment.