From f9b427c4a77265a8318b25ec6f240c37b3544c6b Mon Sep 17 00:00:00 2001 From: SEOB Date: Wed, 24 Jul 2024 02:07:28 +0900 Subject: [PATCH 1/9] =?UTF-8?q?SB-205=20(feat)=20:=20ShippingRepository=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SB-205 (feat) : ShippingRepository 구현 1. ShippingRepository 2. ShippingEntity 3. ShippingStatus 4. GoodsEntity -> shippingId 필드 추가 --- .../java/db/domain/goods/GoodsEntity.java | 2 + .../db/domain/shipping/ShippingEntity.java | 38 +++++++++++++++++++ .../domain/shipping/ShippingRepository.java | 13 +++++++ .../domain/shipping/enums/ShippingStatus.java | 21 ++++++++++ 4 files changed, 74 insertions(+) create mode 100644 db/src/main/java/db/domain/shipping/ShippingEntity.java create mode 100644 db/src/main/java/db/domain/shipping/ShippingRepository.java create mode 100644 db/src/main/java/db/domain/shipping/enums/ShippingStatus.java diff --git a/db/src/main/java/db/domain/goods/GoodsEntity.java b/db/src/main/java/db/domain/goods/GoodsEntity.java index be1cbd2e..a9a6187e 100644 --- a/db/src/main/java/db/domain/goods/GoodsEntity.java +++ b/db/src/main/java/db/domain/goods/GoodsEntity.java @@ -52,4 +52,6 @@ public class GoodsEntity extends BaseEntity { @Column(length = 50, nullable = false, columnDefinition = "VARCHAR(50)") private GoodsStatus status; + private Long shippingId; + } diff --git a/db/src/main/java/db/domain/shipping/ShippingEntity.java b/db/src/main/java/db/domain/shipping/ShippingEntity.java new file mode 100644 index 00000000..451a20f9 --- /dev/null +++ b/db/src/main/java/db/domain/shipping/ShippingEntity.java @@ -0,0 +1,38 @@ +package db.domain.shipping; + +import db.common.BaseEntity; +import db.domain.shipping.enums.ShippingStatus; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.Table; +import java.time.LocalDateTime; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +@AllArgsConstructor +@Entity +@Table(name = "shipping") +@SuperBuilder +public class ShippingEntity extends BaseEntity { + + private LocalDateTime deliveryDate; + + private String deliveryAddress; + + @Enumerated(EnumType.STRING) + @Column(length = 50, nullable = false, columnDefinition = "VARCHAR(50)") + private ShippingStatus status; + + private Long userId; + + private Long deliveryMan; + +} diff --git a/db/src/main/java/db/domain/shipping/ShippingRepository.java b/db/src/main/java/db/domain/shipping/ShippingRepository.java new file mode 100644 index 00000000..11c4da66 --- /dev/null +++ b/db/src/main/java/db/domain/shipping/ShippingRepository.java @@ -0,0 +1,13 @@ +package db.domain.shipping; + +import java.util.List; +import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ShippingRepository extends JpaRepository { + + List findAllByUserIdOrderByIdDesc(Long userId); + + Optional findFirstById(Long shippingId); + +} diff --git a/db/src/main/java/db/domain/shipping/enums/ShippingStatus.java b/db/src/main/java/db/domain/shipping/enums/ShippingStatus.java new file mode 100644 index 00000000..9dba83b6 --- /dev/null +++ b/db/src/main/java/db/domain/shipping/enums/ShippingStatus.java @@ -0,0 +1,21 @@ +package db.domain.shipping.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ShippingStatus { + + PENDING(1,"출고 대기 중","출고 대기 중 입니다."), + DELIVERY(2,"출고 중","물건을 안전하게 출고 중입니다."), + SHIPPED(3,"출고 완료", "물건이 지정된 장소에 도착하였습니다."), + CLOSE(4, "CLOSE", "요청이 닫힌 상태입니다.") + ; + + private final int current; + private final String status; + private final String description; + +} + From 5c0c1ef3db3911f928d1256d8f4d74fac12f4e6d Mon Sep 17 00:00:00 2001 From: SEOB Date: Wed, 24 Jul 2024 02:08:03 +0900 Subject: [PATCH 2/9] =?UTF-8?q?SB-209=20(feat)=20:=20=EC=B6=9C=EA=B3=A0=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=20=EC=B2=98=EB=A6=AC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/error/ShippingErrorCode.java | 18 ++++++++++ .../exception/ShippingExceptionHandler.java | 23 +++++++++++++ .../shipping/ShippingNotFoundException.java | 34 +++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 warehouse/src/main/java/warehouse/common/error/ShippingErrorCode.java create mode 100644 warehouse/src/main/java/warehouse/common/exception/ShippingExceptionHandler.java create mode 100644 warehouse/src/main/java/warehouse/common/exception/shipping/ShippingNotFoundException.java diff --git a/warehouse/src/main/java/warehouse/common/error/ShippingErrorCode.java b/warehouse/src/main/java/warehouse/common/error/ShippingErrorCode.java new file mode 100644 index 00000000..943e5343 --- /dev/null +++ b/warehouse/src/main/java/warehouse/common/error/ShippingErrorCode.java @@ -0,0 +1,18 @@ +package warehouse.common.error; + +import global.errorcode.ErrorCodeIfs; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.springframework.http.HttpStatus; + +@Getter +@AllArgsConstructor +public enum ShippingErrorCode implements ErrorCodeIfs { + + SHIPPING_REQUEST_NOT_FOUND(HttpStatus.NOT_FOUND.value(), 1500, "출고 요청서가 존재하지 않습니다.") + ; + + private final Integer httpCode; + private final Integer errorCode; + private final String description; +} diff --git a/warehouse/src/main/java/warehouse/common/exception/ShippingExceptionHandler.java b/warehouse/src/main/java/warehouse/common/exception/ShippingExceptionHandler.java new file mode 100644 index 00000000..a7d58ae1 --- /dev/null +++ b/warehouse/src/main/java/warehouse/common/exception/ShippingExceptionHandler.java @@ -0,0 +1,23 @@ +package warehouse.common.exception; + +import global.api.Api; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import warehouse.common.error.ShippingErrorCode; +import warehouse.common.exception.shipping.ShippingNotFoundException; + +@Slf4j +@RestControllerAdvice +public class ShippingExceptionHandler { + + @ExceptionHandler(value = ShippingNotFoundException.class) + public ResponseEntity> shippingNotFoundException(ShippingNotFoundException e) { + log.info("", e); + return ResponseEntity.status(HttpStatus.NOT_FOUND) + .body(Api.ERROR(ShippingErrorCode.SHIPPING_REQUEST_NOT_FOUND)); + } + +} diff --git a/warehouse/src/main/java/warehouse/common/exception/shipping/ShippingNotFoundException.java b/warehouse/src/main/java/warehouse/common/exception/shipping/ShippingNotFoundException.java new file mode 100644 index 00000000..c04b974d --- /dev/null +++ b/warehouse/src/main/java/warehouse/common/exception/shipping/ShippingNotFoundException.java @@ -0,0 +1,34 @@ +package warehouse.common.exception.shipping; + +import global.errorcode.ErrorCodeIfs; + +public class ShippingNotFoundException extends RuntimeException { + + private final ErrorCodeIfs errorCodeIfs; + private final String description; + + public ShippingNotFoundException(ErrorCodeIfs errorCodeIfs) { + super(errorCodeIfs.getDescription()); + this.errorCodeIfs = errorCodeIfs; + this.description = errorCodeIfs.getDescription(); + } + + public ShippingNotFoundException(ErrorCodeIfs errorCodeIfs, String errorDescription) { + this.errorCodeIfs = errorCodeIfs; + this.description = errorDescription; + } + + public ShippingNotFoundException(ErrorCodeIfs errorCodeIfs, Throwable throwable) { + super(throwable); + this.errorCodeIfs = errorCodeIfs; + this.description = errorCodeIfs.getDescription(); + } + + public ShippingNotFoundException(ErrorCodeIfs errorCodeIfs, Throwable throwable, + String errorDescription) { + super(throwable); + this.errorCodeIfs = errorCodeIfs; + this.description = errorDescription; + } + +} From 5571705c2836d0308355df79a13ce3fa20489883 Mon Sep 17 00:00:00 2001 From: SEOB Date: Wed, 24 Jul 2024 02:11:28 +0900 Subject: [PATCH 3/9] =?UTF-8?q?SB-206=20(feat)=20:=20=EC=B6=9C=EA=B3=A0=20?= =?UTF-8?q?=EC=8B=A0=EC=B2=AD=20=EA=B8=B0=EB=8A=A5=20=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SB-206 (feat) : 출고 신청 기능 개발 출고 요청 시 1. goodsStatus 가 STORAGE 인지 확인 2. shippingStatus PENDING(출고 대기) 로 변경 3. goodsStatus 가 SHIPPING_ING 로 변경 --- .../java/db/domain/goods/GoodsRepository.java | 3 +- .../domain/goods/service/GoodsService.java | 12 +++- .../shipping/business/ShippingBusiness.java | 64 +++++++++++++++++++ .../controller/ShippingApiController.java | 36 +++++++++++ .../model/request/ShippingRequest.java | 20 ++++++ .../model/response/MessageResponse.java | 16 +++++ .../shipping/converter/ShippingConverter.java | 29 +++++++++ .../shipping/service/ShippingService.java | 23 +++++++ 8 files changed, 198 insertions(+), 5 deletions(-) create mode 100644 warehouse/src/main/java/warehouse/domain/shipping/business/ShippingBusiness.java create mode 100644 warehouse/src/main/java/warehouse/domain/shipping/controller/ShippingApiController.java create mode 100644 warehouse/src/main/java/warehouse/domain/shipping/controller/model/request/ShippingRequest.java create mode 100644 warehouse/src/main/java/warehouse/domain/shipping/controller/model/response/MessageResponse.java create mode 100644 warehouse/src/main/java/warehouse/domain/shipping/converter/ShippingConverter.java create mode 100644 warehouse/src/main/java/warehouse/domain/shipping/service/ShippingService.java diff --git a/db/src/main/java/db/domain/goods/GoodsRepository.java b/db/src/main/java/db/domain/goods/GoodsRepository.java index 7d635bdb..3b017f23 100644 --- a/db/src/main/java/db/domain/goods/GoodsRepository.java +++ b/db/src/main/java/db/domain/goods/GoodsRepository.java @@ -18,7 +18,6 @@ public interface GoodsRepository extends JpaRepository { List findAllByTakeBackIdOrderByIdDesc(Long takeBackId); - //TODO 출고 시스템 완료 후 구현 예정 - //List findAllByShippingIdOrderByIdDesc(Long takeBackId); + List findAllByShippingIdOrderByIdDesc(Long takeBackId); } diff --git a/warehouse/src/main/java/warehouse/domain/goods/service/GoodsService.java b/warehouse/src/main/java/warehouse/domain/goods/service/GoodsService.java index 27c63f2d..6758a410 100644 --- a/warehouse/src/main/java/warehouse/domain/goods/service/GoodsService.java +++ b/warehouse/src/main/java/warehouse/domain/goods/service/GoodsService.java @@ -133,8 +133,7 @@ public List findAllByTakeBackIdWithThrow(Long takeBackId) { return goodsEntityList; } - //TODO 출고 시스템 완료 후 구현 예정 - /*public List findAllByShippingIdWithThrow(Long shippingId) { + public List findAllByShippingIdWithThrow(Long shippingId) { List goodsEntityList = goodsRepository.findAllByShippingIdOrderByIdDesc( shippingId); @@ -143,6 +142,13 @@ public List findAllByTakeBackIdWithThrow(Long takeBackId) { throw new GoodsNotFoundException(GoodsErrorCode.GOODS_NOT_FOUND); } return goodsEntityList; - }*/ + } + + public void setShippingId(List goodsIdList, Long shippingId) { + goodsRepository.findAllByIdIn(goodsIdList).forEach(goodsEntity -> { + goodsEntity.setShippingId(shippingId); + goodsRepository.save(goodsEntity); + }); + } } \ No newline at end of file diff --git a/warehouse/src/main/java/warehouse/domain/shipping/business/ShippingBusiness.java b/warehouse/src/main/java/warehouse/domain/shipping/business/ShippingBusiness.java new file mode 100644 index 00000000..af2ffb3d --- /dev/null +++ b/warehouse/src/main/java/warehouse/domain/shipping/business/ShippingBusiness.java @@ -0,0 +1,64 @@ +package warehouse.domain.shipping.business; + +import db.domain.goods.GoodsEntity; +import db.domain.goods.enums.GoodsStatus; +import db.domain.image.ImageEntity; +import db.domain.image.enums.ImageKind; +import db.domain.shipping.ShippingEntity; +import global.annotation.Business; +import java.util.List; +import java.util.stream.Collectors; +import lombok.RequiredArgsConstructor; +import warehouse.domain.goods.controller.model.GoodsResponse; +import warehouse.domain.goods.converter.GoodsConverter; +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.ShippingDetailResponse; +import warehouse.domain.shipping.controller.model.response.ShippingListResponse; +import warehouse.domain.shipping.controller.model.response.MessageResponse; +import warehouse.domain.shipping.controller.model.response.ShippingResponse; +import warehouse.domain.shipping.converter.ShippingConverter; +import warehouse.domain.shipping.service.ShippingService; +import warehouse.domain.users.service.UsersService; + +@Business +@RequiredArgsConstructor +public class ShippingBusiness { + + private final UsersService usersService; + private final GoodsService goodsService; + private final ShippingService shippingService; + private final ImageService imageService; + private final ShippingConverter shippingConverter; + private final GoodsConverter goodsConverter; + private final ImageConverter imageConverter; + + + public MessageResponse shippingRequest(ShippingRequest request, String email) { + + // 상품이 STORAGE 인지 확인 + goodsService.checkStoredGoodsAndStatusWithThrowBy(request.getGoodsId(), + GoodsStatus.STORAGE); + + Long userId = usersService.getUserWithThrow(email).getId(); + + ShippingEntity shippingEntity = shippingConverter.toEntity(request); + + ShippingEntity savedShippingEntity = shippingService.shippingRequest(shippingEntity, userId); + + // GoodsStatus 를 SHIPPING_ING 으로 변경 + goodsService.setGoodsStatusBy(request.getGoodsId(), GoodsStatus.SHIPPING_ING); + + // goods 컬럼에 shipping_id 부여 + goodsService.setShippingId(request.getGoodsId(), savedShippingEntity.getId()); + + return shippingConverter.toMessageResponse("출고 신청이 완료되었습니다."); + + } + + + +} diff --git a/warehouse/src/main/java/warehouse/domain/shipping/controller/ShippingApiController.java b/warehouse/src/main/java/warehouse/domain/shipping/controller/ShippingApiController.java new file mode 100644 index 00000000..5652cb2f --- /dev/null +++ b/warehouse/src/main/java/warehouse/domain/shipping/controller/ShippingApiController.java @@ -0,0 +1,36 @@ +package warehouse.domain.shipping.controller; + +import global.annotation.ApiValid; +import global.api.Api; +import lombok.RequiredArgsConstructor; +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.security.core.userdetails.User; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +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; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/shipping") +public class ShippingApiController { + + private final ShippingBusiness shippingBusiness; + + @PostMapping() + public Api shippingRequest(@AuthenticationPrincipal User user, + @RequestBody @ApiValid Api request) { + MessageResponse response = shippingBusiness.shippingRequest(request.getBody(), + user.getUsername()); + return Api.OK(response); + } + + +} diff --git a/warehouse/src/main/java/warehouse/domain/shipping/controller/model/request/ShippingRequest.java b/warehouse/src/main/java/warehouse/domain/shipping/controller/model/request/ShippingRequest.java new file mode 100644 index 00000000..8688b0c5 --- /dev/null +++ b/warehouse/src/main/java/warehouse/domain/shipping/controller/model/request/ShippingRequest.java @@ -0,0 +1,20 @@ +package warehouse.domain.shipping.controller.model.request; + +import java.time.LocalDateTime; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ShippingRequest { + + private LocalDateTime deliveryDate; + + private String deliveryAddress; + + private List goodsId; + +} diff --git a/warehouse/src/main/java/warehouse/domain/shipping/controller/model/response/MessageResponse.java b/warehouse/src/main/java/warehouse/domain/shipping/controller/model/response/MessageResponse.java new file mode 100644 index 00000000..d0a6435e --- /dev/null +++ b/warehouse/src/main/java/warehouse/domain/shipping/controller/model/response/MessageResponse.java @@ -0,0 +1,16 @@ +package warehouse.domain.shipping.controller.model.response; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class MessageResponse { + + String message; + +} diff --git a/warehouse/src/main/java/warehouse/domain/shipping/converter/ShippingConverter.java b/warehouse/src/main/java/warehouse/domain/shipping/converter/ShippingConverter.java new file mode 100644 index 00000000..7de25ec4 --- /dev/null +++ b/warehouse/src/main/java/warehouse/domain/shipping/converter/ShippingConverter.java @@ -0,0 +1,29 @@ +package warehouse.domain.shipping.converter; + +import db.domain.shipping.ShippingEntity; +import global.annotation.Converter; +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; + +@Converter +public class ShippingConverter { + + public ShippingEntity toEntity(ShippingRequest request) { + return ShippingEntity.builder() + .deliveryDate(request.getDeliveryDate()) + .deliveryAddress(request.getDeliveryAddress()) + .build(); + } + + public MessageResponse toMessageResponse(String message) { + return MessageResponse.builder() + .message(message) + .build(); + } +} diff --git a/warehouse/src/main/java/warehouse/domain/shipping/service/ShippingService.java b/warehouse/src/main/java/warehouse/domain/shipping/service/ShippingService.java new file mode 100644 index 00000000..8579b93f --- /dev/null +++ b/warehouse/src/main/java/warehouse/domain/shipping/service/ShippingService.java @@ -0,0 +1,23 @@ +package warehouse.domain.shipping.service; + +import db.domain.shipping.ShippingEntity; +import db.domain.shipping.ShippingRepository; +import db.domain.shipping.enums.ShippingStatus; +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import warehouse.common.error.ShippingErrorCode; +import warehouse.common.exception.shipping.ShippingNotFoundException; + +@Service +@RequiredArgsConstructor +public class ShippingService { + + private final ShippingRepository shippingRepository; + + public ShippingEntity shippingRequest(ShippingEntity shippingEntity, Long userId) { + shippingEntity.setUserId(userId); + shippingEntity.setStatus(ShippingStatus.PENDING); // PENDING(출고 대기) 으로 변경 + return shippingRepository.save(shippingEntity); + } + From fead11a441826a943241549b97b10b8ccfebd5ba Mon Sep 17 00:00:00 2001 From: SEOB Date: Wed, 24 Jul 2024 02:13:22 +0900 Subject: [PATCH 4/9] =?UTF-8?q?SB-207=20(feat)=20:=20=EC=B6=9C=EA=B3=A0=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=EC=84=9C=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SB-207 (feat) : 출고 요청서 목록 조회 기능 개발 1. --- .../shipping/business/ShippingBusiness.java | 10 +++++++ .../controller/ShippingApiController.java | 6 +++++ .../model/response/ShippingListResponse.java | 15 +++++++++++ .../model/response/ShippingResponse.java | 26 +++++++++++++++++++ .../shipping/converter/ShippingConverter.java | 20 ++++++++++++++ .../shipping/service/ShippingService.java | 4 +++ 6 files changed, 81 insertions(+) create mode 100644 warehouse/src/main/java/warehouse/domain/shipping/controller/model/response/ShippingListResponse.java create mode 100644 warehouse/src/main/java/warehouse/domain/shipping/controller/model/response/ShippingResponse.java 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 af2ffb3d..05026749 100644 --- a/warehouse/src/main/java/warehouse/domain/shipping/business/ShippingBusiness.java +++ b/warehouse/src/main/java/warehouse/domain/shipping/business/ShippingBusiness.java @@ -60,5 +60,15 @@ public MessageResponse shippingRequest(ShippingRequest request, String email) { } + public ShippingListResponse getShippingList(String email) { + + Long userId = usersService.getUserWithThrow(email).getId(); + + List shippingEntityList = shippingService.getShippingList(userId); + + return shippingConverter.toResponseList(shippingEntityList); + + } + } 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 5652cb2f..a7adf815 100644 --- a/warehouse/src/main/java/warehouse/domain/shipping/controller/ShippingApiController.java +++ b/warehouse/src/main/java/warehouse/domain/shipping/controller/ShippingApiController.java @@ -32,5 +32,11 @@ public Api shippingRequest(@AuthenticationPrincipal User user, return Api.OK(response); } + @GetMapping() //목록조회 + public Api getShippingList(@AuthenticationPrincipal User user) { + ShippingListResponse response = shippingBusiness.getShippingList(user.getUsername()); + return Api.OK(response); + } + } 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 new file mode 100644 index 00000000..cfad062c --- /dev/null +++ b/warehouse/src/main/java/warehouse/domain/shipping/controller/model/response/ShippingListResponse.java @@ -0,0 +1,15 @@ +package warehouse.domain.shipping.controller.model.response; + +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class ShippingListResponse { + List shipping; +} 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 new file mode 100644 index 00000000..9ece259f --- /dev/null +++ b/warehouse/src/main/java/warehouse/domain/shipping/controller/model/response/ShippingResponse.java @@ -0,0 +1,26 @@ +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 7de25ec4..cd711aa6 100644 --- a/warehouse/src/main/java/warehouse/domain/shipping/converter/ShippingConverter.java +++ b/warehouse/src/main/java/warehouse/domain/shipping/converter/ShippingConverter.java @@ -26,4 +26,24 @@ public MessageResponse toMessageResponse(String message) { .message(message) .build(); } + + public ShippingListResponse toResponseList(List entityList) { + + List shippingResponses = entityList.stream() + .map(entity -> this.toResponse(entity)).collect(Collectors.toList()); + + return ShippingListResponse.builder() + .shipping(shippingResponses) + .build(); + } + + public ShippingResponse toResponse(ShippingEntity entity) { + return ShippingResponse.builder() + .shippingId(entity.getId()) + .deliveryDate(entity.getDeliveryDate()) + .deliveryAddress(entity.getDeliveryAddress()) + .status(entity.getStatus()) + .deliveryMan(entity.getDeliveryMan()) + .build(); + } } diff --git a/warehouse/src/main/java/warehouse/domain/shipping/service/ShippingService.java b/warehouse/src/main/java/warehouse/domain/shipping/service/ShippingService.java index 8579b93f..1cd5a4a2 100644 --- a/warehouse/src/main/java/warehouse/domain/shipping/service/ShippingService.java +++ b/warehouse/src/main/java/warehouse/domain/shipping/service/ShippingService.java @@ -21,3 +21,7 @@ public ShippingEntity shippingRequest(ShippingEntity shippingEntity, Long userId return shippingRepository.save(shippingEntity); } + public List getShippingList(Long userId) { + return shippingRepository.findAllByUserIdOrderByIdDesc(userId); + } + From aa8a3e2352b4a785965f64d903963291421b694e Mon Sep 17 00:00:00 2001 From: SEOB Date: Wed, 24 Jul 2024 02:14:57 +0900 Subject: [PATCH 5/9] =?UTF-8?q?SB-208=20(feat)=20:=20=EC=B6=9C=EA=B3=A0=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=EC=84=9C=20=EC=83=81=EC=84=B8=20=EB=B3=B4?= =?UTF-8?q?=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=20=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SB-208 (feat) : 출고 요청서 상세 보기 기능 개발 1. 응답으로 goods/image 포함 2. --- .../shipping/business/ShippingBusiness.java | 29 +++++++++++++++++++ .../controller/ShippingApiController.java | 5 ++++ .../response/ShippingDetailResponse.java | 19 ++++++++++++ .../shipping/converter/ShippingConverter.java | 9 ++++++ .../shipping/service/ShippingService.java | 6 ++++ 5 files changed, 68 insertions(+) create mode 100644 warehouse/src/main/java/warehouse/domain/shipping/controller/model/response/ShippingDetailResponse.java 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 05026749..4a0f7212 100644 --- a/warehouse/src/main/java/warehouse/domain/shipping/business/ShippingBusiness.java +++ b/warehouse/src/main/java/warehouse/domain/shipping/business/ShippingBusiness.java @@ -70,5 +70,34 @@ public ShippingListResponse getShippingList(String email) { } + public ShippingDetailResponse getShippingDetail(Long shippingId) { + + ShippingEntity shippingEntity = shippingService.getShippingDetail(shippingId); + + ShippingResponse shippingResponse = shippingConverter.toResponse(shippingEntity); + + List goodsIdList = goodsService.findAllByShippingIdWithThrow(shippingId).stream() + .map(entity -> entity.getId()).collect(Collectors.toList()); + + List goodsEntityList = goodsService.getGoodsListBy(goodsIdList); + + List goodsResponse = goodsEntityList.stream() + .map(entity -> getGoodsResponse(entity)).collect(Collectors.toList()); + + return shippingConverter.toResponse(shippingResponse, goodsResponse); + + } + + + private GoodsResponse getGoodsResponse(GoodsEntity goodsEntity) { + List basicImageEntityList = imageService.getImageUrlListBy(goodsEntity.getId(), + ImageKind.BASIC); + List faultImageEntityList = imageService.getImageUrlListBy(goodsEntity.getId(), + ImageKind.FAULT); + ImageListResponse imageListResponse = imageConverter.toImageListResponse( + basicImageEntityList, faultImageEntityList); + return goodsConverter.toResponse(goodsEntity, imageListResponse); + } + } 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 a7adf815..f535a6c2 100644 --- a/warehouse/src/main/java/warehouse/domain/shipping/controller/ShippingApiController.java +++ b/warehouse/src/main/java/warehouse/domain/shipping/controller/ShippingApiController.java @@ -38,5 +38,10 @@ public Api getShippingList(@AuthenticationPrincipal User u return Api.OK(response); } + @GetMapping("/{shippingId}") //상세조회 + public Api getShippingDetail(@PathVariable Long shippingId) { + ShippingDetailResponse response = shippingBusiness.getShippingDetail(shippingId); + 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 new file mode 100644 index 00000000..ddfa5b5b --- /dev/null +++ b/warehouse/src/main/java/warehouse/domain/shipping/controller/model/response/ShippingDetailResponse.java @@ -0,0 +1,19 @@ +package warehouse.domain.shipping.controller.model.response; + +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 ShippingDetailResponse { + + private ShippingResponse shipping; + private List goods; + +} 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 cd711aa6..17ad0f8a 100644 --- a/warehouse/src/main/java/warehouse/domain/shipping/converter/ShippingConverter.java +++ b/warehouse/src/main/java/warehouse/domain/shipping/converter/ShippingConverter.java @@ -46,4 +46,13 @@ public ShippingResponse toResponse(ShippingEntity entity) { .deliveryMan(entity.getDeliveryMan()) .build(); } + + public ShippingDetailResponse toResponse(ShippingResponse shippingResponse, + List goodsResponses) { + return ShippingDetailResponse.builder() + .shipping(shippingResponse) + .goods(goodsResponses) + .build(); + } + } diff --git a/warehouse/src/main/java/warehouse/domain/shipping/service/ShippingService.java b/warehouse/src/main/java/warehouse/domain/shipping/service/ShippingService.java index 1cd5a4a2..558479a2 100644 --- a/warehouse/src/main/java/warehouse/domain/shipping/service/ShippingService.java +++ b/warehouse/src/main/java/warehouse/domain/shipping/service/ShippingService.java @@ -25,3 +25,9 @@ public List getShippingList(Long userId) { return shippingRepository.findAllByUserIdOrderByIdDesc(userId); } + public ShippingEntity getShippingDetail(Long shippingId) { + return shippingRepository.findFirstById(shippingId).orElseThrow( + () -> new ShippingNotFoundException(ShippingErrorCode.SHIPPING_REQUEST_NOT_FOUND)); + } + +} From 4668b52d7d45090015078569b9b6ae6b6fd254e4 Mon Sep 17 00:00:00 2001 From: SEOB Date: Wed, 24 Jul 2024 02:36:34 +0900 Subject: [PATCH 6/9] =?UTF-8?q?SB-210=20(feat)=20:=20=EC=B6=9C=EA=B3=A0=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=20=EC=A0=9C=EC=95=BD=EC=A1=B0=EA=B1=B4=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SB-210 (feat) : 출고 요청 제약조건 설정 1. ShippingRequest - deliveryAddress 는 최대 200자 까지 - goodsId 는 적어도 1개 이상 입력해야함 2. ShippingEntity - userId 는 null 불가 --- db/src/main/java/db/domain/shipping/ShippingEntity.java | 2 ++ .../shipping/controller/model/request/ShippingRequest.java | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/db/src/main/java/db/domain/shipping/ShippingEntity.java b/db/src/main/java/db/domain/shipping/ShippingEntity.java index 451a20f9..57032575 100644 --- a/db/src/main/java/db/domain/shipping/ShippingEntity.java +++ b/db/src/main/java/db/domain/shipping/ShippingEntity.java @@ -25,12 +25,14 @@ public class ShippingEntity extends BaseEntity { private LocalDateTime deliveryDate; + @Column(nullable = false, length = 200) private String deliveryAddress; @Enumerated(EnumType.STRING) @Column(length = 50, nullable = false, columnDefinition = "VARCHAR(50)") private ShippingStatus status; + @Column(nullable = false) private Long userId; private Long deliveryMan; diff --git a/warehouse/src/main/java/warehouse/domain/shipping/controller/model/request/ShippingRequest.java b/warehouse/src/main/java/warehouse/domain/shipping/controller/model/request/ShippingRequest.java index 8688b0c5..35f25bb1 100644 --- a/warehouse/src/main/java/warehouse/domain/shipping/controller/model/request/ShippingRequest.java +++ b/warehouse/src/main/java/warehouse/domain/shipping/controller/model/request/ShippingRequest.java @@ -1,5 +1,8 @@ package warehouse.domain.shipping.controller.model.request; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; import java.time.LocalDateTime; import java.util.List; import lombok.AllArgsConstructor; @@ -13,8 +16,12 @@ public class ShippingRequest { private LocalDateTime deliveryDate; + @NotBlank + @Size(max = 200) private String deliveryAddress; + @NotNull + @Size(min = 1) private List goodsId; } From 7a84a381dad028695a17f1b943b5d6260ec16bcb Mon Sep 17 00:00:00 2001 From: SEOB Date: Wed, 24 Jul 2024 02:45:25 +0900 Subject: [PATCH 7/9] =?UTF-8?q?SB-211=20(refactor)=20:=20goodsId=20->=20go?= =?UTF-8?q?odsIdList=EB=A1=9C=20=EB=B3=80=EC=88=98=EB=AA=85=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SB-211 (refactor) : goodsId -> goodsIdList로 변수명 변경 1. ShippingRequest - goodsId -> goodsIdList 로 변경 2. checkStoredGoodsAndStatusWithThrowBy(), setGoodsStatusBy() 에 사용하던 goodsId 변수를 goodsIdList 로 변경 --- .../domain/shipping/business/ShippingBusiness.java | 6 +++--- .../shipping/controller/model/request/ShippingRequest.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) 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 4a0f7212..dd5298c6 100644 --- a/warehouse/src/main/java/warehouse/domain/shipping/business/ShippingBusiness.java +++ b/warehouse/src/main/java/warehouse/domain/shipping/business/ShippingBusiness.java @@ -40,7 +40,7 @@ public class ShippingBusiness { public MessageResponse shippingRequest(ShippingRequest request, String email) { // 상품이 STORAGE 인지 확인 - goodsService.checkStoredGoodsAndStatusWithThrowBy(request.getGoodsId(), + goodsService.checkStoredGoodsAndStatusWithThrowBy(request.getGoodsIdList(), GoodsStatus.STORAGE); Long userId = usersService.getUserWithThrow(email).getId(); @@ -50,10 +50,10 @@ public MessageResponse shippingRequest(ShippingRequest request, String email) { ShippingEntity savedShippingEntity = shippingService.shippingRequest(shippingEntity, userId); // GoodsStatus 를 SHIPPING_ING 으로 변경 - goodsService.setGoodsStatusBy(request.getGoodsId(), GoodsStatus.SHIPPING_ING); + goodsService.setGoodsStatusBy(request.getGoodsIdList(), GoodsStatus.SHIPPING_ING); // goods 컬럼에 shipping_id 부여 - goodsService.setShippingId(request.getGoodsId(), savedShippingEntity.getId()); + goodsService.setShippingId(request.getGoodsIdList(), savedShippingEntity.getId()); return shippingConverter.toMessageResponse("출고 신청이 완료되었습니다."); diff --git a/warehouse/src/main/java/warehouse/domain/shipping/controller/model/request/ShippingRequest.java b/warehouse/src/main/java/warehouse/domain/shipping/controller/model/request/ShippingRequest.java index 35f25bb1..92957511 100644 --- a/warehouse/src/main/java/warehouse/domain/shipping/controller/model/request/ShippingRequest.java +++ b/warehouse/src/main/java/warehouse/domain/shipping/controller/model/request/ShippingRequest.java @@ -22,6 +22,6 @@ public class ShippingRequest { @NotNull @Size(min = 1) - private List goodsId; + private List goodsIdList; } From 0b2a081e453aa7a6675ed8b8758317337cbdfef2 Mon Sep 17 00:00:00 2001 From: SEOB Date: Wed, 24 Jul 2024 13:29:22 +0900 Subject: [PATCH 8/9] =?UTF-8?q?SB-212=20(refactor)=20:=20setShippingId()?= =?UTF-8?q?=20=EC=B1=85=EC=9E=84=20=EB=B6=84=EB=A6=AC=20&=20ShippingStatus?= =?UTF-8?q?=20REGISTERED=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SB-212 (refactor) : setShippingId() 책임 분리 & ShippingStatus REGISTERED 추가 --- .../main/java/db/domain/shipping/enums/ShippingStatus.java | 7 ++++--- .../java/warehouse/domain/goods/service/GoodsService.java | 4 ++-- .../domain/shipping/business/ShippingBusiness.java | 4 +++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/db/src/main/java/db/domain/shipping/enums/ShippingStatus.java b/db/src/main/java/db/domain/shipping/enums/ShippingStatus.java index 9dba83b6..4790fc44 100644 --- a/db/src/main/java/db/domain/shipping/enums/ShippingStatus.java +++ b/db/src/main/java/db/domain/shipping/enums/ShippingStatus.java @@ -8,9 +8,10 @@ public enum ShippingStatus { PENDING(1,"출고 대기 중","출고 대기 중 입니다."), - DELIVERY(2,"출고 중","물건을 안전하게 출고 중입니다."), - SHIPPED(3,"출고 완료", "물건이 지정된 장소에 도착하였습니다."), - CLOSE(4, "CLOSE", "요청이 닫힌 상태입니다.") + REGISTERED(2,"출고 접수 완료", "출고 일정이 확정되었습니다."), + DELIVERY(3,"출고 중","물건을 안전하게 출고 중입니다."), + SHIPPED(4,"출고 완료", "물건이 지정된 장소에 도착하였습니다."), + CLOSE(5, "CLOSE", "요청이 닫힌 상태입니다.") ; private final int current; diff --git a/warehouse/src/main/java/warehouse/domain/goods/service/GoodsService.java b/warehouse/src/main/java/warehouse/domain/goods/service/GoodsService.java index 6758a410..80325cfe 100644 --- a/warehouse/src/main/java/warehouse/domain/goods/service/GoodsService.java +++ b/warehouse/src/main/java/warehouse/domain/goods/service/GoodsService.java @@ -144,8 +144,8 @@ public List findAllByShippingIdWithThrow(Long shippingId) { return goodsEntityList; } - public void setShippingId(List goodsIdList, Long shippingId) { - goodsRepository.findAllByIdIn(goodsIdList).forEach(goodsEntity -> { + public void setShippingId(List goodsEntityList, Long shippingId) { + goodsEntityList.forEach(goodsEntity -> { goodsEntity.setShippingId(shippingId); goodsRepository.save(goodsEntity); }); 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 dd5298c6..30a379ec 100644 --- a/warehouse/src/main/java/warehouse/domain/shipping/business/ShippingBusiness.java +++ b/warehouse/src/main/java/warehouse/domain/shipping/business/ShippingBusiness.java @@ -52,8 +52,10 @@ public MessageResponse shippingRequest(ShippingRequest request, String email) { // GoodsStatus 를 SHIPPING_ING 으로 변경 goodsService.setGoodsStatusBy(request.getGoodsIdList(), GoodsStatus.SHIPPING_ING); + List goodsEntityList = goodsService.getGoodsListBy(request.getGoodsIdList()); + // goods 컬럼에 shipping_id 부여 - goodsService.setShippingId(request.getGoodsIdList(), savedShippingEntity.getId()); + goodsService.setShippingId(goodsEntityList, savedShippingEntity.getId()); return shippingConverter.toMessageResponse("출고 신청이 완료되었습니다."); From f2bc64ff140df3c1f6b4db3f9e8aaa4ac2f94b08 Mon Sep 17 00:00:00 2001 From: shinyeongwoon Date: Wed, 24 Jul 2024 17:07:49 +0900 Subject: [PATCH 9/9] =?UTF-8?q?SB-214=20(!HOTFIX)=20:=20`/api/goods`=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=20=EA=B2=B0=EA=B3=BC=20=EA=B0=92=EC=97=90?= =?UTF-8?q?=EC=84=9C=20body=EC=9D=98=202=EC=B0=A8=EC=9B=90=20=EB=B0=B0?= =?UTF-8?q?=EC=97=B4=EC=9D=84=201=EC=B0=A8=EC=9B=90=20=EB=B0=B0=EC=97=B4?= =?UTF-8?q?=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SB-214 (!HOTFIX) : `/api/goods` 요청 결과 값에서 body의 2차원 배열을 1차원 배열로 수정 1. 불필요 차원 축소 - 2차원 -> 1차원 2. /api/goods/{strategy}/{requestId} 동일 적용 3. Goods Import 수정 --- .../exception/Goods/InvalidGoodsStatusException.java | 2 +- .../common/exception/GoodsExceptionHandler.java | 5 ++--- .../warehouse/domain/goods/business/GoodsBusiness.java | 10 +++++----- .../domain/goods/controller/GoodsController.java | 8 ++++---- .../warehouse/domain/goods/service/GoodsService.java | 2 +- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/warehouse/src/main/java/warehouse/common/exception/Goods/InvalidGoodsStatusException.java b/warehouse/src/main/java/warehouse/common/exception/Goods/InvalidGoodsStatusException.java index 48d650c0..896f4dc2 100644 --- a/warehouse/src/main/java/warehouse/common/exception/Goods/InvalidGoodsStatusException.java +++ b/warehouse/src/main/java/warehouse/common/exception/Goods/InvalidGoodsStatusException.java @@ -1,4 +1,4 @@ -package warehouse.common.exception.goods; +package warehouse.common.exception.Goods; import global.errorcode.ErrorCodeIfs; diff --git a/warehouse/src/main/java/warehouse/common/exception/GoodsExceptionHandler.java b/warehouse/src/main/java/warehouse/common/exception/GoodsExceptionHandler.java index 148f4fd6..bdcbac2d 100644 --- a/warehouse/src/main/java/warehouse/common/exception/GoodsExceptionHandler.java +++ b/warehouse/src/main/java/warehouse/common/exception/GoodsExceptionHandler.java @@ -8,7 +8,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; import warehouse.common.error.GoodsErrorCode; -import warehouse.common.exception.goods.InvalidGoodsStatusException; +import warehouse.common.exception.Goods.InvalidGoodsStatusException; import warehouse.common.exception.goods.GoodsNotFoundException; @Slf4j @@ -24,8 +24,7 @@ public ResponseEntity> imageException(GoodsNotFoundException e) { } @ExceptionHandler(value = InvalidGoodsStatusException.class) - public ResponseEntity> InvalidGoodsStatus( - warehouse.common.exception.goods.InvalidGoodsStatusException e) { + public ResponseEntity> InvalidGoodsStatus(InvalidGoodsStatusException e) { log.info("", e); return ResponseEntity.status(HttpStatus.BAD_REQUEST) .body(Api.ERROR(GoodsErrorCode.INVALID_GOODS_STATUS)); diff --git a/warehouse/src/main/java/warehouse/domain/goods/business/GoodsBusiness.java b/warehouse/src/main/java/warehouse/domain/goods/business/GoodsBusiness.java index 5aadb31f..6240e26c 100644 --- a/warehouse/src/main/java/warehouse/domain/goods/business/GoodsBusiness.java +++ b/warehouse/src/main/java/warehouse/domain/goods/business/GoodsBusiness.java @@ -29,23 +29,23 @@ public class GoodsBusiness { private final ImageService imageService; private final ImageConverter imageConverter; - public List> getGoodsList(GetGoodsStrategy strategy,Long requestId) { + public List getGoodsList(GetGoodsStrategy strategy,Long requestId) { List goodsList = findGoodsListById(strategy,requestId); return getGoodsResponsesBy(goodsList); } - public List> getGoodsList(GoodsStatus status) { + public List getGoodsList(GoodsStatus status) { List goodsList = goodsService.findAllByGoodsStatusWithThrow(status); return getGoodsResponsesBy(goodsList); } - private List> getGoodsResponsesBy(List goodsList) { + private List getGoodsResponsesBy(List goodsList) { - List> goodsResponse = new ArrayList<>(); + List goodsResponse = new ArrayList<>(); goodsList.forEach(goodsEntity -> { @@ -63,7 +63,7 @@ private List> getGoodsResponsesBy(List goodsLis ImageListResponse imageListResponse = imageConverter.toImageListResponse(basicList, faultList); - goodsResponse.add(goodsConverter.toResponseListBy(goodsList, imageListResponse)); + goodsResponse.add(goodsConverter.toResponse(goodsEntity, imageListResponse)); }); diff --git a/warehouse/src/main/java/warehouse/domain/goods/controller/GoodsController.java b/warehouse/src/main/java/warehouse/domain/goods/controller/GoodsController.java index 22a3267d..3c55ff86 100644 --- a/warehouse/src/main/java/warehouse/domain/goods/controller/GoodsController.java +++ b/warehouse/src/main/java/warehouse/domain/goods/controller/GoodsController.java @@ -21,14 +21,14 @@ public class GoodsController { private final GoodsBusiness goodsBusiness; @GetMapping("/{strategy}/{requestId}") - public Api>> receiving(@PathVariable GetGoodsStrategy strategy, @PathVariable Long requestId) { - List> response = goodsBusiness.getGoodsList(strategy,requestId); + public Api> receiving(@PathVariable GetGoodsStrategy strategy, @PathVariable Long requestId) { + List response = goodsBusiness.getGoodsList(strategy,requestId); return Api.OK(response); } @GetMapping() - public Api>> getGoodsByStatus(@RequestParam GoodsStatus status) { - List> response = goodsBusiness.getGoodsList(status); + public Api> getGoodsByStatus(@RequestParam GoodsStatus status) { + List response = goodsBusiness.getGoodsList(status); return Api.OK(response); } diff --git a/warehouse/src/main/java/warehouse/domain/goods/service/GoodsService.java b/warehouse/src/main/java/warehouse/domain/goods/service/GoodsService.java index 80325cfe..8e8d45df 100644 --- a/warehouse/src/main/java/warehouse/domain/goods/service/GoodsService.java +++ b/warehouse/src/main/java/warehouse/domain/goods/service/GoodsService.java @@ -10,8 +10,8 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import warehouse.common.error.GoodsErrorCode; +import warehouse.common.exception.Goods.InvalidGoodsStatusException; import warehouse.common.exception.goods.GoodsNotFoundException; -import warehouse.common.exception.goods.InvalidGoodsStatusException; @Service @RequiredArgsConstructor