From cfd34eede7066d871089c229406689357f7edd12 Mon Sep 17 00:00:00 2001 From: shinyeongwoon Date: Tue, 20 Aug 2024 14:27:50 +0900 Subject: [PATCH 01/12] =?UTF-8?q?SB-270=20(feat)=20:=20=EB=82=A0=EC=A7=9C?= =?UTF-8?q?=EB=A1=9C=20=EC=9E=85=EA=B3=A0=20=EC=98=88=EC=95=BD=20=ED=99=95?= =?UTF-8?q?=EC=A0=95=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SB-270 (feat) : 날짜로 입고 예약 확정 목록 조회 1. 날짜로 입고 예약 확정 목록 조회 기능 구현 - Controller, Business, Repository 구현 2. DateTimeUtils 구현 - 출고 예약 목록 조회 기능에 재사용 예정 --- .../domain/receiving/ReceivingRepository.java | 4 ++ .../common/utils/datetime/DateTimeUtils.java | 37 ++++++++++++ .../receiving/business/ReceivingBusiness.java | 56 ++++++++++++------- .../controller/ReceivingApiController.java | 12 ++++ .../receiving/service/ReceivingService.java | 11 ++++ 5 files changed, 100 insertions(+), 20 deletions(-) create mode 100644 delivery/src/main/java/delivery/common/utils/datetime/DateTimeUtils.java diff --git a/db/src/main/java/db/domain/receiving/ReceivingRepository.java b/db/src/main/java/db/domain/receiving/ReceivingRepository.java index 91220ea2..9452f318 100644 --- a/db/src/main/java/db/domain/receiving/ReceivingRepository.java +++ b/db/src/main/java/db/domain/receiving/ReceivingRepository.java @@ -1,8 +1,10 @@ package db.domain.receiving; import db.domain.receiving.enums.ReceivingStatus; +import java.time.LocalDateTime; import java.util.List; import java.util.Optional; +import jdk.jshell.Snippet.Kind; import org.springframework.data.jpa.repository.JpaRepository; public interface ReceivingRepository extends JpaRepository { @@ -12,4 +14,6 @@ public interface ReceivingRepository extends JpaRepository findAllByUserIdOrderByIdDesc(Long userId); List findAllByStatusOrderByVisitDate(ReceivingStatus receivingStatus); + + List findAllByStatusAndVisitDateBetweenOrderByUserId (ReceivingStatus receivingStatus, LocalDateTime startDate, LocalDateTime dueDate); } diff --git a/delivery/src/main/java/delivery/common/utils/datetime/DateTimeUtils.java b/delivery/src/main/java/delivery/common/utils/datetime/DateTimeUtils.java new file mode 100644 index 00000000..6a55231d --- /dev/null +++ b/delivery/src/main/java/delivery/common/utils/datetime/DateTimeUtils.java @@ -0,0 +1,37 @@ +package delivery.common.utils.datetime; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.stereotype.Component; + +@Component +public class DateTimeUtils { + + private static String startDate; + private static String dueDate; + private static DateTimeFormatter formatter; + + public static RequestDateTime getStartAndDueDate(String date){ + startDate = date + " 00:00:00.000"; + dueDate = date + " 23:59:59.999"; + formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"); + + return RequestDateTime.builder() + .startDateTime(LocalDateTime.parse(startDate, formatter)) + .dueDateTime(LocalDateTime.parse(dueDate, formatter)) + .build(); + } + + @Data + @NoArgsConstructor + @AllArgsConstructor + @Builder + public static class RequestDateTime{ + private LocalDateTime startDateTime; + private LocalDateTime dueDateTime; + } +} diff --git a/delivery/src/main/java/delivery/domain/receiving/business/ReceivingBusiness.java b/delivery/src/main/java/delivery/domain/receiving/business/ReceivingBusiness.java index 730de5f0..2f4da095 100644 --- a/delivery/src/main/java/delivery/domain/receiving/business/ReceivingBusiness.java +++ b/delivery/src/main/java/delivery/domain/receiving/business/ReceivingBusiness.java @@ -3,6 +3,8 @@ import db.domain.goods.GoodsEntity; import db.domain.receiving.ReceivingEntity; import db.domain.users.UserEntity; +import delivery.common.utils.datetime.DateTimeUtils; +import delivery.common.utils.datetime.DateTimeUtils.RequestDateTime; import delivery.domain.goods.converter.GoodsConverter; import delivery.domain.goods.service.GoodsService; import delivery.domain.receiving.controller.model.ReceivingResponse; @@ -12,6 +14,8 @@ import delivery.domain.users.converter.UserConverter; import delivery.domain.users.service.UserService; import global.annotation.Business; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; import lombok.RequiredArgsConstructor; @@ -34,26 +38,7 @@ public ReceivingResponseList getReservationList() { List receivingEntityList = receivingService.getRequestList(); - ReceivingResponseList responseList = receivingConverter.toResponseList(receivingEntityList); - - receivingEntityList.forEach(receivingEntity -> { - - log.info("receivingList Id : {} ", receivingEntity.getId()); - - List goodsIdList = goodsService.getReceivingGoodsList(receivingEntity.getId()) - .stream().map(goodsEntity -> { - return goodsEntity.getId(); - }).toList(); - - responseList.getReservationResponseList().forEach(reservationResponse -> { - reservationResponse.setGoodsIdList(goodsIdList); - reservationResponse.setUserName( - userService.getUserBy(receivingEntity.getUserId()).getName()); - }); - - }); - - return responseList; + return getResponseList(receivingEntityList); } public ReceivingResponse getReservation(Long requestId) { @@ -91,4 +76,35 @@ private ReceivingResponse setGoodsIdAndUserNameReceivingResponse( } + public ReceivingResponseList showReservationByDate(String date) { + + RequestDateTime dateTime = DateTimeUtils.getStartAndDueDate(date); + List receivingEntityList = receivingService.getRequestListByDate(dateTime.getStartDateTime(),dateTime.getDueDateTime()); + + return getResponseList(receivingEntityList); + + } + + private ReceivingResponseList getResponseList(List receivingEntityList) { + ReceivingResponseList responseList = receivingConverter.toResponseList(receivingEntityList); + + receivingEntityList.forEach(receivingEntity -> { + + log.info("receivingList Id : {} ", receivingEntity.getId()); + + List goodsIdList = goodsService.getReceivingGoodsList(receivingEntity.getId()) + .stream().map(goodsEntity -> { + return goodsEntity.getId(); + }).toList(); + + responseList.getReservationResponseList().forEach(reservationResponse -> { + reservationResponse.setGoodsIdList(goodsIdList); + reservationResponse.setUserName( + userService.getUserBy(receivingEntity.getUserId()).getName()); + }); + + }); + + return responseList; + } } diff --git a/delivery/src/main/java/delivery/domain/receiving/controller/ReceivingApiController.java b/delivery/src/main/java/delivery/domain/receiving/controller/ReceivingApiController.java index 50172a07..1f3ad525 100644 --- a/delivery/src/main/java/delivery/domain/receiving/controller/ReceivingApiController.java +++ b/delivery/src/main/java/delivery/domain/receiving/controller/ReceivingApiController.java @@ -4,11 +4,14 @@ import delivery.domain.receiving.controller.model.ReceivingResponse; import delivery.domain.receiving.controller.model.ReceivingResponseList; import global.api.Api; +import java.time.LocalDate; +import java.time.LocalDateTime; import lombok.RequiredArgsConstructor; 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.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @RestController @@ -38,4 +41,13 @@ public Api receivingReservation( return Api.OK(response); } + // TODO Login DeliveryMan 정보 활용 필요 + @GetMapping("/reservation") + public Api showReservationByDate( + @RequestParam String date + ){ + ReceivingResponseList response = receivingBusiness.showReservationByDate(date); + return Api.OK(response); + } + } diff --git a/delivery/src/main/java/delivery/domain/receiving/service/ReceivingService.java b/delivery/src/main/java/delivery/domain/receiving/service/ReceivingService.java index 80e2f1a8..0e9000f5 100644 --- a/delivery/src/main/java/delivery/domain/receiving/service/ReceivingService.java +++ b/delivery/src/main/java/delivery/domain/receiving/service/ReceivingService.java @@ -7,6 +7,7 @@ import delivery.common.exception.receiving.ReceivingNotFoundException; import delivery.common.exception.receiving.ReceivingNotInTakingException; import delivery.domain.receiving.controller.model.ReceivingResponse; +import java.time.LocalDateTime; import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -46,4 +47,14 @@ public ReceivingEntity reservationConfirmed(Long requestId) { receivingEntity.setStatus(ReceivingStatus.CONFIRMATION); return receivingRepository.save(receivingEntity); } + + public List getRequestListByDate(LocalDateTime startDate,LocalDateTime dueDate) { + List receivingEntityList = receivingRepository.findAllByStatusAndVisitDateBetweenOrderByUserId( + ReceivingStatus.CONFIRMATION, startDate, dueDate); + + if (receivingEntityList.isEmpty()) { + throw new ReceivingNotFoundException(ReceivingErrorCode.RECEIVING_REQUEST_NOT_FOUND); + } + return receivingEntityList; + } } From 7a0e0960827189b541ac2aa0ac46262c26545602 Mon Sep 17 00:00:00 2001 From: shinyeongwoon Date: Tue, 20 Aug 2024 14:52:08 +0900 Subject: [PATCH 02/12] =?UTF-8?q?SB-271=20(feat)=20:=20=EB=82=A0=EC=A7=9C?= =?UTF-8?q?=EB=A1=9C=20=EC=B6=9C=EA=B3=A0=20=EC=98=88=EC=95=BD=20=ED=99=95?= =?UTF-8?q?=EC=A0=95=20=EB=AA=A9=EB=A1=9D=20=EB=B3=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SB-271 (feat) : 날짜로 출고 예약 확정 목록 보기 1. 날짜로 출고 예약 확정 목록 조회 - Controller, Business,Service ,Repository 구현 --- .../domain/shipping/ShippingRepository.java | 4 +- .../shipping/business/ShippingBusiness.java | 56 ++++++++++++------- .../controller/ShippingApiController.java | 10 ++++ .../shipping/service/ShippingService.java | 13 +++++ 4 files changed, 61 insertions(+), 22 deletions(-) diff --git a/db/src/main/java/db/domain/shipping/ShippingRepository.java b/db/src/main/java/db/domain/shipping/ShippingRepository.java index fd946bcf..b4fa426b 100644 --- a/db/src/main/java/db/domain/shipping/ShippingRepository.java +++ b/db/src/main/java/db/domain/shipping/ShippingRepository.java @@ -1,7 +1,7 @@ package db.domain.shipping; -import db.domain.receiving.ReceivingEntity; import db.domain.shipping.enums.ShippingStatus; +import java.time.LocalDateTime; import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; @@ -14,4 +14,6 @@ public interface ShippingRepository extends JpaRepository List findAllByStatusOrderByDeliveryDate(ShippingStatus shippingStatus); + List findAllByStatusAndDeliveryDateBetweenOrderByUserId(ShippingStatus status, + LocalDateTime startDate, LocalDateTime dueDate); } diff --git a/delivery/src/main/java/delivery/domain/shipping/business/ShippingBusiness.java b/delivery/src/main/java/delivery/domain/shipping/business/ShippingBusiness.java index 1c7ddd38..b24b8c1f 100644 --- a/delivery/src/main/java/delivery/domain/shipping/business/ShippingBusiness.java +++ b/delivery/src/main/java/delivery/domain/shipping/business/ShippingBusiness.java @@ -3,6 +3,8 @@ import db.domain.receiving.ReceivingEntity; import db.domain.shipping.ShippingEntity; import db.domain.users.UserEntity; +import delivery.common.utils.datetime.DateTimeUtils; +import delivery.common.utils.datetime.DateTimeUtils.RequestDateTime; import delivery.domain.goods.converter.GoodsConverter; import delivery.domain.goods.service.GoodsService; import delivery.domain.receiving.controller.model.ReceivingResponseList; @@ -33,27 +35,7 @@ public ShippingResponseList getReservationList() { List shippingEntityList = shippingService.getRequestList(); - ShippingResponseList responseList = shippingConverter.toResponseList(shippingEntityList); - - shippingEntityList.forEach(shippingEntity -> { - - log.info("receivingList Id : {} " , shippingEntity.getId()); - - List goodsIdList = goodsService.getShippingGoodsList(shippingEntity.getId()).stream().map( - goodsEntity -> { - return goodsEntity.getId(); - } - ).toList(); - - responseList.getReservationResponseList().forEach(reservationResponse -> { - reservationResponse.setGoodsIdList(goodsIdList); - reservationResponse.setUserName(userService.getUserBy(shippingEntity.getUserId()).getName()); - }); - - }); - - return responseList; - + return getResponseList(shippingEntityList); } public ShippingResponse getReservation(Long requestId) { @@ -88,4 +70,36 @@ private ShippingResponse getShippingResponse(ShippingEntity shippingEntity) { return response; } + + public ShippingResponseList showReservationByDate(String date) { + + RequestDateTime dateTime = DateTimeUtils.getStartAndDueDate(date); + + List shippingEntityList = shippingService.getRequestListByDate(dateTime.getStartDateTime(),dateTime.getDueDateTime()); + + return getResponseList(shippingEntityList); + } + + private ShippingResponseList getResponseList(List shippingEntityList) { + ShippingResponseList responseList = shippingConverter.toResponseList(shippingEntityList); + + shippingEntityList.forEach(shippingEntity -> { + + log.info("receivingList Id : {} " , shippingEntity.getId()); + + List goodsIdList = goodsService.getShippingGoodsList(shippingEntity.getId()).stream().map( + goodsEntity -> { + return goodsEntity.getId(); + } + ).toList(); + + responseList.getReservationResponseList().forEach(reservationResponse -> { + reservationResponse.setGoodsIdList(goodsIdList); + reservationResponse.setUserName(userService.getUserBy(shippingEntity.getUserId()).getName()); + }); + + }); + + return responseList; + } } diff --git a/delivery/src/main/java/delivery/domain/shipping/controller/ShippingApiController.java b/delivery/src/main/java/delivery/domain/shipping/controller/ShippingApiController.java index 4f67e31d..c722a246 100644 --- a/delivery/src/main/java/delivery/domain/shipping/controller/ShippingApiController.java +++ b/delivery/src/main/java/delivery/domain/shipping/controller/ShippingApiController.java @@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @RestController @@ -39,4 +40,13 @@ public Api shippingReservation( return Api.OK(response); } + // TODO Login DeliveryMan 정보 활용 필요 + @GetMapping("/reservation") + public Api showReservationByDate( + @RequestParam String date + ){ + ShippingResponseList response = shippingBusiness.showReservationByDate(date); + return Api.OK(response); + } + } diff --git a/delivery/src/main/java/delivery/domain/shipping/service/ShippingService.java b/delivery/src/main/java/delivery/domain/shipping/service/ShippingService.java index d8df77d7..ac6445fa 100644 --- a/delivery/src/main/java/delivery/domain/shipping/service/ShippingService.java +++ b/delivery/src/main/java/delivery/domain/shipping/service/ShippingService.java @@ -5,9 +5,12 @@ import db.domain.shipping.ShippingEntity; import db.domain.shipping.ShippingRepository; import db.domain.shipping.enums.ShippingStatus; +import delivery.common.error.ReceivingErrorCode; import delivery.common.error.ShippingErrorCode; +import delivery.common.exception.receiving.ReceivingNotFoundException; import delivery.common.exception.shipping.ShippingNotFoundException; import delivery.common.exception.shipping.ShippingNotInPendingException; +import java.time.LocalDateTime; import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -48,4 +51,14 @@ public ShippingEntity reservationConfirmed(Long requestId) { return shippingRepository.save(shippingEntity); } + + public List getRequestListByDate(LocalDateTime startDate, LocalDateTime dueDate) { + List receivingEntityList = shippingRepository.findAllByStatusAndDeliveryDateBetweenOrderByUserId( + ShippingStatus.REGISTERED, startDate, dueDate); + + if (receivingEntityList.isEmpty()) { + throw new ReceivingNotFoundException(ReceivingErrorCode.RECEIVING_REQUEST_NOT_FOUND); + } + return receivingEntityList; + } } From f688dbcbd6f23ed1bd0c0da60b219fa795b2ab8c Mon Sep 17 00:00:00 2001 From: shinyeongwoon Date: Tue, 20 Aug 2024 15:26:23 +0900 Subject: [PATCH 03/12] =?UTF-8?q?SB-272=20(feat)=20:=20=EC=9E=85=EA=B3=A0?= =?UTF-8?q?=20=EB=B0=B0=EC=86=A1=20=EC=8B=9C=EC=9E=91=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SB-272 (feat) : 입고 배송 시작하기 1. 입고 배송 시작하기 - Controller, Business, Service 구현 2. Confirmation 상태가 아닐 시 Exception 발생 - Exception, Exception Handler, ErrorCode 추가 --- .../common/error/ReceivingErrorCode.java | 3 +- .../exception/ReceivingExceptionHandler.java | 8 +++++ .../ReceivingNotInConfirmationException.java | 34 +++++++++++++++++++ .../receiving/business/ReceivingBusiness.java | 27 ++++++++++++--- .../controller/ReceivingApiController.java | 14 +++++--- .../receiving/service/ReceivingService.java | 5 +++ 6 files changed, 81 insertions(+), 10 deletions(-) create mode 100644 delivery/src/main/java/delivery/common/exception/receiving/ReceivingNotInConfirmationException.java diff --git a/delivery/src/main/java/delivery/common/error/ReceivingErrorCode.java b/delivery/src/main/java/delivery/common/error/ReceivingErrorCode.java index 01bb3b07..0041ed0e 100644 --- a/delivery/src/main/java/delivery/common/error/ReceivingErrorCode.java +++ b/delivery/src/main/java/delivery/common/error/ReceivingErrorCode.java @@ -11,7 +11,8 @@ public enum ReceivingErrorCode implements ErrorCodeIfs { RECEIVING_REQUEST_NOT_FOUND(HttpStatus.NOT_FOUND.value(), 1250, "입고 요청서가 존재하지 않습니다."), NO_OWNERSHIP(HttpStatus.BAD_REQUEST.value(), 1251, "사용자의 물품이 아닙니다."), - RECEIVING_NOT_IN_TAKING(HttpStatus.BAD_REQUEST.value(), 1252,"입고요청서 상태가 절적하지 않습니다.") + RECEIVING_NOT_IN_TAKING(HttpStatus.BAD_REQUEST.value(), 1252,"입고 요청 상태가 아닙니다."), + RECEIVING_NOT_IN_CONFIRMATION(HttpStatus.NOT_FOUND.value(),1253,"입고 확정 상태가 아닙니다."), ; private final Integer httpCode; diff --git a/delivery/src/main/java/delivery/common/exception/ReceivingExceptionHandler.java b/delivery/src/main/java/delivery/common/exception/ReceivingExceptionHandler.java index a178b3af..f7b720f5 100644 --- a/delivery/src/main/java/delivery/common/exception/ReceivingExceptionHandler.java +++ b/delivery/src/main/java/delivery/common/exception/ReceivingExceptionHandler.java @@ -3,6 +3,7 @@ import delivery.common.error.ReceivingErrorCode; import delivery.common.exception.receiving.NoOwnershipException; import delivery.common.exception.receiving.ReceivingNotFoundException; +import delivery.common.exception.receiving.ReceivingNotInConfirmationException; import delivery.common.exception.receiving.ReceivingNotInTakingException; import global.api.Api; import lombok.extern.slf4j.Slf4j; @@ -37,5 +38,12 @@ public ResponseEntity> receivingNotInTakingException(ReceivingNotInT return ResponseEntity.status(HttpStatus.BAD_REQUEST) .body(Api.ERROR(ReceivingErrorCode.RECEIVING_NOT_IN_TAKING)); } + + @ExceptionHandler(value = ReceivingNotInConfirmationException.class) + public ResponseEntity> receivingNotInConfirmationException(ReceivingNotInConfirmationException e) { + log.info("", e); + return ResponseEntity.status(HttpStatus.BAD_REQUEST) + .body(Api.ERROR(ReceivingErrorCode.RECEIVING_NOT_IN_CONFIRMATION)); + } } diff --git a/delivery/src/main/java/delivery/common/exception/receiving/ReceivingNotInConfirmationException.java b/delivery/src/main/java/delivery/common/exception/receiving/ReceivingNotInConfirmationException.java new file mode 100644 index 00000000..ae30c65f --- /dev/null +++ b/delivery/src/main/java/delivery/common/exception/receiving/ReceivingNotInConfirmationException.java @@ -0,0 +1,34 @@ +package delivery.common.exception.receiving; + +import global.errorcode.ErrorCodeIfs; + +public class ReceivingNotInConfirmationException extends RuntimeException { + + private final ErrorCodeIfs errorCodeIfs; + private final String description; + + public ReceivingNotInConfirmationException(ErrorCodeIfs errorCodeIfs) { + super(errorCodeIfs.getDescription()); + this.errorCodeIfs = errorCodeIfs; + this.description = errorCodeIfs.getDescription(); + } + + public ReceivingNotInConfirmationException(ErrorCodeIfs errorCodeIfs, String errorDescription) { + this.errorCodeIfs = errorCodeIfs; + this.description = errorDescription; + } + + public ReceivingNotInConfirmationException(ErrorCodeIfs errorCodeIfs, Throwable throwable) { + super(throwable); + this.errorCodeIfs = errorCodeIfs; + this.description = errorCodeIfs.getDescription(); + } + + public ReceivingNotInConfirmationException(ErrorCodeIfs errorCodeIfs, Throwable throwable, + String errorDescription) { + super(throwable); + this.errorCodeIfs = errorCodeIfs; + this.description = errorDescription; + } + +} \ No newline at end of file diff --git a/delivery/src/main/java/delivery/domain/receiving/business/ReceivingBusiness.java b/delivery/src/main/java/delivery/domain/receiving/business/ReceivingBusiness.java index 2f4da095..48972cde 100644 --- a/delivery/src/main/java/delivery/domain/receiving/business/ReceivingBusiness.java +++ b/delivery/src/main/java/delivery/domain/receiving/business/ReceivingBusiness.java @@ -1,8 +1,11 @@ package delivery.domain.receiving.business; -import db.domain.goods.GoodsEntity; import db.domain.receiving.ReceivingEntity; +import db.domain.receiving.enums.ReceivingStatus; import db.domain.users.UserEntity; +import delivery.common.error.ReceivingErrorCode; +import delivery.common.error.ShippingErrorCode; +import delivery.common.exception.receiving.ReceivingNotInConfirmationException; import delivery.common.utils.datetime.DateTimeUtils; import delivery.common.utils.datetime.DateTimeUtils.RequestDateTime; import delivery.domain.goods.converter.GoodsConverter; @@ -14,9 +17,6 @@ import delivery.domain.users.converter.UserConverter; import delivery.domain.users.service.UserService; import global.annotation.Business; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -79,7 +79,8 @@ private ReceivingResponse setGoodsIdAndUserNameReceivingResponse( public ReceivingResponseList showReservationByDate(String date) { RequestDateTime dateTime = DateTimeUtils.getStartAndDueDate(date); - List receivingEntityList = receivingService.getRequestListByDate(dateTime.getStartDateTime(),dateTime.getDueDateTime()); + List receivingEntityList = receivingService.getRequestListByDate( + dateTime.getStartDateTime(), dateTime.getDueDateTime()); return getResponseList(receivingEntityList); @@ -107,4 +108,20 @@ private ReceivingResponseList getResponseList(List receivingEnt return responseList; } + + public ReceivingResponse deliveryStart(Long requestId) { + + ReceivingEntity receivingEntity = receivingService.getRequestBy(requestId); + + if (receivingEntity.getStatus() != ReceivingStatus.CONFIRMATION) { + throw new ReceivingNotInConfirmationException( + ReceivingErrorCode.RECEIVING_NOT_IN_CONFIRMATION); + } + + ReceivingEntity updateEntity = receivingService.startDelivery(receivingEntity); + + ReceivingResponse receivingResponse = setGoodsIdAndUserNameReceivingResponse(updateEntity); + + return receivingResponse; + } } diff --git a/delivery/src/main/java/delivery/domain/receiving/controller/ReceivingApiController.java b/delivery/src/main/java/delivery/domain/receiving/controller/ReceivingApiController.java index 1f3ad525..31e804dc 100644 --- a/delivery/src/main/java/delivery/domain/receiving/controller/ReceivingApiController.java +++ b/delivery/src/main/java/delivery/domain/receiving/controller/ReceivingApiController.java @@ -22,13 +22,13 @@ public class ReceivingApiController { private final ReceivingBusiness receivingBusiness; @GetMapping - public Api showReservationList(){ + public Api showReservationList() { ReceivingResponseList response = receivingBusiness.getReservationList(); return Api.OK(response); } @GetMapping("/{requestId}") - public Api showReservation(@PathVariable Long requestId){ + public Api showReservation(@PathVariable Long requestId) { ReceivingResponse response = receivingBusiness.getReservation(requestId); return Api.OK(response); } @@ -36,7 +36,7 @@ public Api showReservation(@PathVariable Long requestId){ @PostMapping("/reservation/{requestId}") public Api receivingReservation( @PathVariable Long requestId - ){ + ) { ReceivingResponse response = receivingBusiness.reservationConfirmed(requestId); return Api.OK(response); } @@ -45,9 +45,15 @@ public Api receivingReservation( @GetMapping("/reservation") public Api showReservationByDate( @RequestParam String date - ){ + ) { ReceivingResponseList response = receivingBusiness.showReservationByDate(date); return Api.OK(response); } + @PostMapping("/start/{requestId}") + public Api deliveryStart(@PathVariable Long requestId) { + ReceivingResponse response = receivingBusiness.deliveryStart(requestId); + return Api.OK(response); + } + } diff --git a/delivery/src/main/java/delivery/domain/receiving/service/ReceivingService.java b/delivery/src/main/java/delivery/domain/receiving/service/ReceivingService.java index 0e9000f5..46add192 100644 --- a/delivery/src/main/java/delivery/domain/receiving/service/ReceivingService.java +++ b/delivery/src/main/java/delivery/domain/receiving/service/ReceivingService.java @@ -57,4 +57,9 @@ public List getRequestListByDate(LocalDateTime startDate,LocalD } return receivingEntityList; } + + public ReceivingEntity startDelivery(ReceivingEntity receivingEntity) { + receivingEntity.setStatus(ReceivingStatus.DELIVERY); + return receivingRepository.save(receivingEntity); + } } From 12ed8c3e2aca268557ad005dc32fa4c4594af905 Mon Sep 17 00:00:00 2001 From: shinyeongwoon Date: Tue, 20 Aug 2024 16:06:35 +0900 Subject: [PATCH 04/12] =?UTF-8?q?SB-273=20(feat)=20:=20=EC=B6=9C=EA=B3=A0?= =?UTF-8?q?=20=EB=B0=B0=EC=86=A1=20=EC=8B=9C=EC=9E=91=20=EA=B8=B0=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SB-273 (feat) : 출고 배송 시작 기능 1. 출고 배송 시작 기능 - Controller, Business, Service, Repository 구현 2. Shipping, Goods Exception 처리 - 출고 배송 시작 시 출고 요청서 상태 확인 - 출고 배송 시작 시 물품 상태 확인 --- .../delivery/common/error/GoodsErrorCode.java | 4 +- .../common/error/ShippingErrorCode.java | 3 +- .../exception/GoodsExceptionHandler.java | 16 ++++++++ .../exception/ShippingExceptionHandler.java | 7 ++++ .../goods/GoodsNotInShippingIngException.java | 34 +++++++++++++++++ .../goods/GoodsNotInStorageException.java | 34 +++++++++++++++++ .../ShippingNotInRegisteredException.java | 34 +++++++++++++++++ .../domain/goods/service/GoodsService.java | 14 +++++++ .../controller/ReceivingApiController.java | 1 + .../shipping/business/ShippingBusiness.java | 37 +++++++++++++++++++ .../controller/ShippingApiController.java | 10 +++++ .../shipping/service/ShippingService.java | 5 +++ 12 files changed, 197 insertions(+), 2 deletions(-) create mode 100644 delivery/src/main/java/delivery/common/exception/goods/GoodsNotInShippingIngException.java create mode 100644 delivery/src/main/java/delivery/common/exception/goods/GoodsNotInStorageException.java create mode 100644 delivery/src/main/java/delivery/common/exception/shipping/ShippingNotInRegisteredException.java diff --git a/delivery/src/main/java/delivery/common/error/GoodsErrorCode.java b/delivery/src/main/java/delivery/common/error/GoodsErrorCode.java index 8068ad9a..89d39bb5 100644 --- a/delivery/src/main/java/delivery/common/error/GoodsErrorCode.java +++ b/delivery/src/main/java/delivery/common/error/GoodsErrorCode.java @@ -12,7 +12,9 @@ public enum GoodsErrorCode implements ErrorCodeIfs { GOODS_NOT_FOUND(HttpStatus.NOT_FOUND.value(), 1200, "물품이 존재하지 않습니다."), INVALID_GOODS_STATUS(HttpStatus.BAD_REQUEST.value(),1201,"잘못된 물품 상태입니다."), INVALID_GOODS_STRATEGY(HttpStatus.BAD_REQUEST.value(), 1202, "요청서 종류가 잘못되었습니다."), - NOT_OWNER(HttpStatus.NOT_ACCEPTABLE.value(), 1203, "소유자가 아닙니다.") + NOT_OWNER(HttpStatus.NOT_ACCEPTABLE.value(), 1203, "소유자가 아닙니다."), + GOODS_NOT_IN_STORAGE(HttpStatus.NOT_FOUND.value(),1253,"입고 확정 상태가 아닙니다."), + GOODS_NOT_IN_SHIPPING_ING(HttpStatus.NOT_FOUND.value(),1253,"상품이 출고 진행 상태가 아닙니다."), ; private final Integer httpCode; diff --git a/delivery/src/main/java/delivery/common/error/ShippingErrorCode.java b/delivery/src/main/java/delivery/common/error/ShippingErrorCode.java index 0e3892c1..d51fd106 100644 --- a/delivery/src/main/java/delivery/common/error/ShippingErrorCode.java +++ b/delivery/src/main/java/delivery/common/error/ShippingErrorCode.java @@ -10,7 +10,8 @@ public enum ShippingErrorCode implements ErrorCodeIfs { SHIPPING_REQUEST_NOT_FOUND(HttpStatus.NOT_FOUND.value(), 1500, "출고 요청서가 존재하지 않습니다."), - SHIPPING_NOT_IN_PENDING(HttpStatus.NOT_FOUND.value(),1501,"출고 요청 상태가 아닙니다.") + SHIPPING_NOT_IN_PENDING(HttpStatus.NOT_FOUND.value(),1501,"출고 요청 상태가 아닙니다."), + SHIPPING_NOT_IN_REGISTERED(HttpStatus.NOT_FOUND.value(),1502,"출고 접수 상태가 아닙니다."), ; private final Integer httpCode; diff --git a/delivery/src/main/java/delivery/common/exception/GoodsExceptionHandler.java b/delivery/src/main/java/delivery/common/exception/GoodsExceptionHandler.java index 438ae5a0..1cee99af 100644 --- a/delivery/src/main/java/delivery/common/exception/GoodsExceptionHandler.java +++ b/delivery/src/main/java/delivery/common/exception/GoodsExceptionHandler.java @@ -2,6 +2,8 @@ import delivery.common.error.GoodsErrorCode; import delivery.common.exception.goods.GoodsNotFoundException; +import delivery.common.exception.goods.GoodsNotInShippingIngException; +import delivery.common.exception.goods.GoodsNotInStorageException; import delivery.common.exception.goods.InvalidGoodsStatusException; import delivery.common.exception.receiving.NotOwnerException; import global.api.Api; @@ -37,4 +39,18 @@ public ResponseEntity> notOwnerException(NotOwnerException e) { return ResponseEntity.status(HttpStatus.BAD_REQUEST) .body(Api.ERROR(GoodsErrorCode.NOT_OWNER)); } + + @ExceptionHandler(value = GoodsNotInStorageException.class) + public ResponseEntity> goodsNotInStorageException(GoodsNotInStorageException e) { + log.info("", e); + return ResponseEntity.status(HttpStatus.BAD_REQUEST) + .body(Api.ERROR(GoodsErrorCode.GOODS_NOT_IN_STORAGE)); + } + + @ExceptionHandler(value = GoodsNotInShippingIngException.class) + public ResponseEntity> goodsNotInShippingIngException(GoodsNotInShippingIngException e) { + log.info("", e); + return ResponseEntity.status(HttpStatus.BAD_REQUEST) + .body(Api.ERROR(GoodsErrorCode.GOODS_NOT_IN_SHIPPING_ING)); + } } diff --git a/delivery/src/main/java/delivery/common/exception/ShippingExceptionHandler.java b/delivery/src/main/java/delivery/common/exception/ShippingExceptionHandler.java index 1488d05d..d0c94d95 100644 --- a/delivery/src/main/java/delivery/common/exception/ShippingExceptionHandler.java +++ b/delivery/src/main/java/delivery/common/exception/ShippingExceptionHandler.java @@ -3,6 +3,7 @@ import delivery.common.error.ShippingErrorCode; import delivery.common.exception.shipping.ShippingNotFoundException; import delivery.common.exception.shipping.ShippingNotInPendingException; +import delivery.common.exception.shipping.ShippingNotInRegisteredException; import global.api.Api; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; @@ -28,5 +29,11 @@ public ResponseEntity> shippingNotFoundException(ShippingNotInPendin .body(Api.ERROR(ShippingErrorCode.SHIPPING_NOT_IN_PENDING)); } + @ExceptionHandler(value = ShippingNotInRegisteredException.class) + public ResponseEntity> shippingNotInRegisteredException(ShippingNotInRegisteredException e) { + log.info("", e); + return ResponseEntity.status(HttpStatus.NOT_FOUND) + .body(Api.ERROR(ShippingErrorCode.SHIPPING_NOT_IN_REGISTERED)); + } } diff --git a/delivery/src/main/java/delivery/common/exception/goods/GoodsNotInShippingIngException.java b/delivery/src/main/java/delivery/common/exception/goods/GoodsNotInShippingIngException.java new file mode 100644 index 00000000..425f80cb --- /dev/null +++ b/delivery/src/main/java/delivery/common/exception/goods/GoodsNotInShippingIngException.java @@ -0,0 +1,34 @@ +package delivery.common.exception.goods; + +import global.errorcode.ErrorCodeIfs; + +public class GoodsNotInShippingIngException extends RuntimeException { + + private final ErrorCodeIfs errorCodeIfs; + private final String description; + + public GoodsNotInShippingIngException(ErrorCodeIfs errorCodeIfs) { + super(errorCodeIfs.getDescription()); + this.errorCodeIfs = errorCodeIfs; + this.description = errorCodeIfs.getDescription(); + } + + public GoodsNotInShippingIngException(ErrorCodeIfs errorCodeIfs, String errorDescription) { + this.errorCodeIfs = errorCodeIfs; + this.description = errorDescription; + } + + public GoodsNotInShippingIngException(ErrorCodeIfs errorCodeIfs, Throwable throwable) { + super(throwable); + this.errorCodeIfs = errorCodeIfs; + this.description = errorCodeIfs.getDescription(); + } + + public GoodsNotInShippingIngException(ErrorCodeIfs errorCodeIfs, Throwable throwable, + String errorDescription) { + super(throwable); + this.errorCodeIfs = errorCodeIfs; + this.description = errorDescription; + } + +} \ No newline at end of file diff --git a/delivery/src/main/java/delivery/common/exception/goods/GoodsNotInStorageException.java b/delivery/src/main/java/delivery/common/exception/goods/GoodsNotInStorageException.java new file mode 100644 index 00000000..f47b59cb --- /dev/null +++ b/delivery/src/main/java/delivery/common/exception/goods/GoodsNotInStorageException.java @@ -0,0 +1,34 @@ +package delivery.common.exception.goods; + +import global.errorcode.ErrorCodeIfs; + +public class GoodsNotInStorageException extends RuntimeException { + + private final ErrorCodeIfs errorCodeIfs; + private final String description; + + public GoodsNotInStorageException(ErrorCodeIfs errorCodeIfs) { + super(errorCodeIfs.getDescription()); + this.errorCodeIfs = errorCodeIfs; + this.description = errorCodeIfs.getDescription(); + } + + public GoodsNotInStorageException(ErrorCodeIfs errorCodeIfs, String errorDescription) { + this.errorCodeIfs = errorCodeIfs; + this.description = errorDescription; + } + + public GoodsNotInStorageException(ErrorCodeIfs errorCodeIfs, Throwable throwable) { + super(throwable); + this.errorCodeIfs = errorCodeIfs; + this.description = errorCodeIfs.getDescription(); + } + + public GoodsNotInStorageException(ErrorCodeIfs errorCodeIfs, Throwable throwable, + String errorDescription) { + super(throwable); + this.errorCodeIfs = errorCodeIfs; + this.description = errorDescription; + } + +} \ No newline at end of file diff --git a/delivery/src/main/java/delivery/common/exception/shipping/ShippingNotInRegisteredException.java b/delivery/src/main/java/delivery/common/exception/shipping/ShippingNotInRegisteredException.java new file mode 100644 index 00000000..d4d31f5e --- /dev/null +++ b/delivery/src/main/java/delivery/common/exception/shipping/ShippingNotInRegisteredException.java @@ -0,0 +1,34 @@ +package delivery.common.exception.shipping; + +import global.errorcode.ErrorCodeIfs; + +public class ShippingNotInRegisteredException extends RuntimeException { + + private final ErrorCodeIfs errorCodeIfs; + private final String description; + + public ShippingNotInRegisteredException(ErrorCodeIfs errorCodeIfs) { + super(errorCodeIfs.getDescription()); + this.errorCodeIfs = errorCodeIfs; + this.description = errorCodeIfs.getDescription(); + } + + public ShippingNotInRegisteredException(ErrorCodeIfs errorCodeIfs, String errorDescription) { + this.errorCodeIfs = errorCodeIfs; + this.description = errorDescription; + } + + public ShippingNotInRegisteredException(ErrorCodeIfs errorCodeIfs, Throwable throwable) { + super(throwable); + this.errorCodeIfs = errorCodeIfs; + this.description = errorCodeIfs.getDescription(); + } + + public ShippingNotInRegisteredException(ErrorCodeIfs errorCodeIfs, Throwable throwable, + String errorDescription) { + super(throwable); + this.errorCodeIfs = errorCodeIfs; + this.description = errorDescription; + } + +} \ No newline at end of file diff --git a/delivery/src/main/java/delivery/domain/goods/service/GoodsService.java b/delivery/src/main/java/delivery/domain/goods/service/GoodsService.java index d6edd7ed..f7a4b6be 100644 --- a/delivery/src/main/java/delivery/domain/goods/service/GoodsService.java +++ b/delivery/src/main/java/delivery/domain/goods/service/GoodsService.java @@ -2,7 +2,11 @@ import db.domain.goods.GoodsEntity; import db.domain.goods.GoodsRepository; +import db.domain.goods.enums.GoodsStatus; +import delivery.common.error.GoodsErrorCode; +import delivery.common.exception.goods.GoodsNotFoundException; import java.util.List; +import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -19,4 +23,14 @@ public List getReceivingGoodsList(Long receivingId) { public List getShippingGoodsList(Long receivingId) { return goodsRepository.findAllByShippingIdOrderByIdDesc(receivingId); } + + public GoodsEntity getGoodsBy(Long goodsId) { + return goodsRepository.findById(goodsId).orElseThrow(() -> new GoodsNotFoundException( + GoodsErrorCode.GOODS_NOT_FOUND)); + } + + public GoodsEntity startShipping(GoodsEntity goodsEntity) { + goodsEntity.setStatus(GoodsStatus.SHIPPING_ING); + return goodsRepository.save(goodsEntity); + } } diff --git a/delivery/src/main/java/delivery/domain/receiving/controller/ReceivingApiController.java b/delivery/src/main/java/delivery/domain/receiving/controller/ReceivingApiController.java index 31e804dc..4a55433f 100644 --- a/delivery/src/main/java/delivery/domain/receiving/controller/ReceivingApiController.java +++ b/delivery/src/main/java/delivery/domain/receiving/controller/ReceivingApiController.java @@ -50,6 +50,7 @@ public Api showReservationByDate( return Api.OK(response); } + // TODO Login DeliveryMan 정보 활용 필요 @PostMapping("/start/{requestId}") public Api deliveryStart(@PathVariable Long requestId) { ReceivingResponse response = receivingBusiness.deliveryStart(requestId); diff --git a/delivery/src/main/java/delivery/domain/shipping/business/ShippingBusiness.java b/delivery/src/main/java/delivery/domain/shipping/business/ShippingBusiness.java index b24b8c1f..ea9e4b55 100644 --- a/delivery/src/main/java/delivery/domain/shipping/business/ShippingBusiness.java +++ b/delivery/src/main/java/delivery/domain/shipping/business/ShippingBusiness.java @@ -1,12 +1,25 @@ package delivery.domain.shipping.business; +import db.domain.goods.GoodsEntity; +import db.domain.goods.enums.GoodsStatus; import db.domain.receiving.ReceivingEntity; +import db.domain.receiving.enums.ReceivingStatus; import db.domain.shipping.ShippingEntity; +import db.domain.shipping.enums.ShippingStatus; import db.domain.users.UserEntity; +import delivery.common.error.GoodsErrorCode; +import delivery.common.error.ReceivingErrorCode; +import delivery.common.error.ShippingErrorCode; +import delivery.common.exception.goods.GoodsNotFoundException; +import delivery.common.exception.goods.GoodsNotInShippingIngException; +import delivery.common.exception.goods.GoodsNotInStorageException; +import delivery.common.exception.receiving.ReceivingNotInConfirmationException; +import delivery.common.exception.shipping.ShippingNotInRegisteredException; import delivery.common.utils.datetime.DateTimeUtils; import delivery.common.utils.datetime.DateTimeUtils.RequestDateTime; import delivery.domain.goods.converter.GoodsConverter; import delivery.domain.goods.service.GoodsService; +import delivery.domain.receiving.controller.model.ReceivingResponse; import delivery.domain.receiving.controller.model.ReceivingResponseList; import delivery.domain.shipping.controller.model.ShippingResponse; import delivery.domain.shipping.controller.model.ShippingResponseList; @@ -16,6 +29,7 @@ import delivery.domain.users.service.UserService; import global.annotation.Business; import java.util.List; +import java.util.Optional; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -102,4 +116,27 @@ private ShippingResponseList getResponseList(List shippingEntity return responseList; } + + public ShippingResponse deliveryStart(Long requestId) { + + ShippingEntity shippingEntity = shippingService.getRequest(requestId); + + if (shippingEntity.getStatus() != ShippingStatus.REGISTERED) { + throw new ShippingNotInRegisteredException( + ShippingErrorCode.SHIPPING_NOT_IN_REGISTERED); + } + + ShippingEntity updateEntity = shippingService.startDelivery(shippingEntity); + + ShippingResponse shippingResponse = getShippingResponse(updateEntity); + + shippingResponse.getGoodsIdList().forEach(goodsId -> { + GoodsEntity goodsEntity = goodsService.getGoodsBy(goodsId); + if (goodsEntity.getStatus() != GoodsStatus.SHIPPING_ING){ + throw new GoodsNotInShippingIngException(GoodsErrorCode.GOODS_NOT_IN_SHIPPING_ING); + } + }); + + return shippingResponse; + } } diff --git a/delivery/src/main/java/delivery/domain/shipping/controller/ShippingApiController.java b/delivery/src/main/java/delivery/domain/shipping/controller/ShippingApiController.java index c722a246..4134827e 100644 --- a/delivery/src/main/java/delivery/domain/shipping/controller/ShippingApiController.java +++ b/delivery/src/main/java/delivery/domain/shipping/controller/ShippingApiController.java @@ -1,5 +1,6 @@ package delivery.domain.shipping.controller; +import delivery.domain.receiving.controller.model.ReceivingResponse; import delivery.domain.receiving.controller.model.ReceivingResponseList; import delivery.domain.shipping.business.ShippingBusiness; import delivery.domain.shipping.controller.model.ShippingResponse; @@ -49,4 +50,13 @@ public Api showReservationByDate( return Api.OK(response); } + // TODO Login DeliveryMan 정보 활용 필요 + @PostMapping("/start/{requestId}") + public Api deliveryStart(@PathVariable Long requestId) { + ShippingResponse response = shippingBusiness.deliveryStart(requestId); + return Api.OK(response); + } + + + } diff --git a/delivery/src/main/java/delivery/domain/shipping/service/ShippingService.java b/delivery/src/main/java/delivery/domain/shipping/service/ShippingService.java index ac6445fa..3b17edf0 100644 --- a/delivery/src/main/java/delivery/domain/shipping/service/ShippingService.java +++ b/delivery/src/main/java/delivery/domain/shipping/service/ShippingService.java @@ -61,4 +61,9 @@ public List getRequestListByDate(LocalDateTime startDate, LocalD } return receivingEntityList; } + + public ShippingEntity startDelivery(ShippingEntity shippingEntity) { + shippingEntity.setStatus(ShippingStatus.DELIVERY); + return shippingRepository.save(shippingEntity); + } } From 223684fb3836867e4fd24d6582230b0029c1e49f Mon Sep 17 00:00:00 2001 From: shinyeongwoon Date: Tue, 20 Aug 2024 16:11:39 +0900 Subject: [PATCH 05/12] =?UTF-8?q?SB-272=20(!HOTFIX)=20:=20=EC=9E=85?= =?UTF-8?q?=EA=B3=A0=20=EB=B0=B0=EC=86=A1=20=EC=8B=9C=EC=9E=91=20=EC=8B=9C?= =?UTF-8?q?=20Goods=20=EC=83=81=ED=83=9C=20=ED=99=95=EC=9D=B8=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SB-272 (!HOTFIX) : 입고 배송 시작 시 Goods 상태 확인 로직 추가 1. 입고 배송 시작 시 Goods 상태 확인 로직 추가 - GoodsNotInReceivingException, ExceptionHandler, ErrorCode 추가 --- .../delivery/common/error/GoodsErrorCode.java | 1 + .../exception/GoodsExceptionHandler.java | 8 +++++ .../goods/GoodsNotInReceivingException.java | 34 +++++++++++++++++++ .../receiving/business/ReceivingBusiness.java | 12 +++++++ 4 files changed, 55 insertions(+) create mode 100644 delivery/src/main/java/delivery/common/exception/goods/GoodsNotInReceivingException.java diff --git a/delivery/src/main/java/delivery/common/error/GoodsErrorCode.java b/delivery/src/main/java/delivery/common/error/GoodsErrorCode.java index 89d39bb5..43f6439b 100644 --- a/delivery/src/main/java/delivery/common/error/GoodsErrorCode.java +++ b/delivery/src/main/java/delivery/common/error/GoodsErrorCode.java @@ -15,6 +15,7 @@ public enum GoodsErrorCode implements ErrorCodeIfs { NOT_OWNER(HttpStatus.NOT_ACCEPTABLE.value(), 1203, "소유자가 아닙니다."), GOODS_NOT_IN_STORAGE(HttpStatus.NOT_FOUND.value(),1253,"입고 확정 상태가 아닙니다."), GOODS_NOT_IN_SHIPPING_ING(HttpStatus.NOT_FOUND.value(),1253,"상품이 출고 진행 상태가 아닙니다."), + GOODS_NOT_IN_RECEIVING(HttpStatus.NOT_FOUND.value(),1253,"상품이 입고 진행 상태가 아닙니다."), ; private final Integer httpCode; diff --git a/delivery/src/main/java/delivery/common/exception/GoodsExceptionHandler.java b/delivery/src/main/java/delivery/common/exception/GoodsExceptionHandler.java index 1cee99af..82c1e29e 100644 --- a/delivery/src/main/java/delivery/common/exception/GoodsExceptionHandler.java +++ b/delivery/src/main/java/delivery/common/exception/GoodsExceptionHandler.java @@ -2,6 +2,7 @@ import delivery.common.error.GoodsErrorCode; import delivery.common.exception.goods.GoodsNotFoundException; +import delivery.common.exception.goods.GoodsNotInReceivingException; import delivery.common.exception.goods.GoodsNotInShippingIngException; import delivery.common.exception.goods.GoodsNotInStorageException; import delivery.common.exception.goods.InvalidGoodsStatusException; @@ -53,4 +54,11 @@ public ResponseEntity> goodsNotInShippingIngException(GoodsNotInShip return ResponseEntity.status(HttpStatus.BAD_REQUEST) .body(Api.ERROR(GoodsErrorCode.GOODS_NOT_IN_SHIPPING_ING)); } + + @ExceptionHandler(value = GoodsNotInReceivingException.class) + public ResponseEntity> goodsNotInReceivingException(GoodsNotInReceivingException e) { + log.info("", e); + return ResponseEntity.status(HttpStatus.BAD_REQUEST) + .body(Api.ERROR(GoodsErrorCode.GOODS_NOT_IN_RECEIVING)); + } } diff --git a/delivery/src/main/java/delivery/common/exception/goods/GoodsNotInReceivingException.java b/delivery/src/main/java/delivery/common/exception/goods/GoodsNotInReceivingException.java new file mode 100644 index 00000000..4548a2f9 --- /dev/null +++ b/delivery/src/main/java/delivery/common/exception/goods/GoodsNotInReceivingException.java @@ -0,0 +1,34 @@ +package delivery.common.exception.goods; + +import global.errorcode.ErrorCodeIfs; + +public class GoodsNotInReceivingException extends RuntimeException { + + private final ErrorCodeIfs errorCodeIfs; + private final String description; + + public GoodsNotInReceivingException(ErrorCodeIfs errorCodeIfs) { + super(errorCodeIfs.getDescription()); + this.errorCodeIfs = errorCodeIfs; + this.description = errorCodeIfs.getDescription(); + } + + public GoodsNotInReceivingException(ErrorCodeIfs errorCodeIfs, String errorDescription) { + this.errorCodeIfs = errorCodeIfs; + this.description = errorDescription; + } + + public GoodsNotInReceivingException(ErrorCodeIfs errorCodeIfs, Throwable throwable) { + super(throwable); + this.errorCodeIfs = errorCodeIfs; + this.description = errorCodeIfs.getDescription(); + } + + public GoodsNotInReceivingException(ErrorCodeIfs errorCodeIfs, Throwable throwable, + String errorDescription) { + super(throwable); + this.errorCodeIfs = errorCodeIfs; + this.description = errorDescription; + } + +} \ No newline at end of file diff --git a/delivery/src/main/java/delivery/domain/receiving/business/ReceivingBusiness.java b/delivery/src/main/java/delivery/domain/receiving/business/ReceivingBusiness.java index 48972cde..ba5de09d 100644 --- a/delivery/src/main/java/delivery/domain/receiving/business/ReceivingBusiness.java +++ b/delivery/src/main/java/delivery/domain/receiving/business/ReceivingBusiness.java @@ -1,10 +1,15 @@ package delivery.domain.receiving.business; +import db.domain.goods.GoodsEntity; +import db.domain.goods.enums.GoodsStatus; import db.domain.receiving.ReceivingEntity; import db.domain.receiving.enums.ReceivingStatus; import db.domain.users.UserEntity; +import delivery.common.error.GoodsErrorCode; import delivery.common.error.ReceivingErrorCode; import delivery.common.error.ShippingErrorCode; +import delivery.common.exception.goods.GoodsNotInReceivingException; +import delivery.common.exception.goods.GoodsNotInShippingIngException; import delivery.common.exception.receiving.ReceivingNotInConfirmationException; import delivery.common.utils.datetime.DateTimeUtils; import delivery.common.utils.datetime.DateTimeUtils.RequestDateTime; @@ -122,6 +127,13 @@ public ReceivingResponse deliveryStart(Long requestId) { ReceivingResponse receivingResponse = setGoodsIdAndUserNameReceivingResponse(updateEntity); + receivingResponse.getGoodsIdList().forEach(goodsId -> { + GoodsEntity goodsEntity = goodsService.getGoodsBy(goodsId); + if (goodsEntity.getStatus() != GoodsStatus.RECEIVING){ + throw new GoodsNotInReceivingException(GoodsErrorCode.GOODS_NOT_IN_RECEIVING); + } + }); + return receivingResponse; } } From 319728a85fd589cb14b1e794a86cee34dfb316b5 Mon Sep 17 00:00:00 2001 From: shinyeongwoon Date: Tue, 20 Aug 2024 18:13:28 +0900 Subject: [PATCH 06/12] =?UTF-8?q?SB-274=20(feat)=20:=20=EC=9E=85=EA=B3=A0?= =?UTF-8?q?=20=EB=B0=B0=EC=86=A1=20=EC=99=84=EB=A3=8C=20=EA=B8=B0=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SB-274 (feat) : 입고 배송 완료 기능 1. 입고 배송 완료 기능 구현 - Controller, Business, Service 구현 2. ReceivingNotInDeliveryException 구현 - ReceivingNotInDeliveryException, ExceptionHandler, ErrorCode 추가 --- .../common/error/ReceivingErrorCode.java | 1 + .../exception/ReceivingExceptionHandler.java | 8 +++++ .../ReceivingNotInDeliveryException.java | 36 +++++++++++++++++++ .../receiving/business/ReceivingBusiness.java | 15 ++++++++ .../controller/ReceivingApiController.java | 7 ++++ .../receiving/service/ReceivingService.java | 5 +++ 6 files changed, 72 insertions(+) create mode 100644 delivery/src/main/java/delivery/common/exception/receiving/ReceivingNotInDeliveryException.java diff --git a/delivery/src/main/java/delivery/common/error/ReceivingErrorCode.java b/delivery/src/main/java/delivery/common/error/ReceivingErrorCode.java index 0041ed0e..a6166a68 100644 --- a/delivery/src/main/java/delivery/common/error/ReceivingErrorCode.java +++ b/delivery/src/main/java/delivery/common/error/ReceivingErrorCode.java @@ -13,6 +13,7 @@ public enum ReceivingErrorCode implements ErrorCodeIfs { NO_OWNERSHIP(HttpStatus.BAD_REQUEST.value(), 1251, "사용자의 물품이 아닙니다."), RECEIVING_NOT_IN_TAKING(HttpStatus.BAD_REQUEST.value(), 1252,"입고 요청 상태가 아닙니다."), RECEIVING_NOT_IN_CONFIRMATION(HttpStatus.NOT_FOUND.value(),1253,"입고 확정 상태가 아닙니다."), + RECEIVING_NOT_IN_DELIVERY(HttpStatus.NOT_FOUND.value(),1254,"입고 배송 상태가 아닙니다."), ; private final Integer httpCode; diff --git a/delivery/src/main/java/delivery/common/exception/ReceivingExceptionHandler.java b/delivery/src/main/java/delivery/common/exception/ReceivingExceptionHandler.java index f7b720f5..cbe261c0 100644 --- a/delivery/src/main/java/delivery/common/exception/ReceivingExceptionHandler.java +++ b/delivery/src/main/java/delivery/common/exception/ReceivingExceptionHandler.java @@ -4,6 +4,7 @@ import delivery.common.exception.receiving.NoOwnershipException; import delivery.common.exception.receiving.ReceivingNotFoundException; import delivery.common.exception.receiving.ReceivingNotInConfirmationException; +import delivery.common.exception.receiving.ReceivingNotInDeliveryException; import delivery.common.exception.receiving.ReceivingNotInTakingException; import global.api.Api; import lombok.extern.slf4j.Slf4j; @@ -45,5 +46,12 @@ public ResponseEntity> receivingNotInConfirmationException(Receiving return ResponseEntity.status(HttpStatus.BAD_REQUEST) .body(Api.ERROR(ReceivingErrorCode.RECEIVING_NOT_IN_CONFIRMATION)); } + + @ExceptionHandler(value = ReceivingNotInDeliveryException.class) + public ResponseEntity> receivingNotInDeliveryException(ReceivingNotInDeliveryException e) { + log.info("", e); + return ResponseEntity.status(HttpStatus.BAD_REQUEST) + .body(Api.ERROR(ReceivingErrorCode.RECEIVING_NOT_IN_DELIVERY)); + } } diff --git a/delivery/src/main/java/delivery/common/exception/receiving/ReceivingNotInDeliveryException.java b/delivery/src/main/java/delivery/common/exception/receiving/ReceivingNotInDeliveryException.java new file mode 100644 index 00000000..9f50ca0e --- /dev/null +++ b/delivery/src/main/java/delivery/common/exception/receiving/ReceivingNotInDeliveryException.java @@ -0,0 +1,36 @@ +package delivery.common.exception.receiving; + +import global.errorcode.ErrorCodeIfs; +import lombok.Getter; + +@Getter +public class ReceivingNotInDeliveryException extends RuntimeException { + + private final ErrorCodeIfs errorCodeIfs; + private final String description; + + public ReceivingNotInDeliveryException(ErrorCodeIfs errorCodeIfs) { + super(errorCodeIfs.getDescription()); + this.errorCodeIfs = errorCodeIfs; + this.description = errorCodeIfs.getDescription(); + } + + public ReceivingNotInDeliveryException(ErrorCodeIfs errorCodeIfs, String errorDescription) { + this.errorCodeIfs = errorCodeIfs; + this.description = errorDescription; + } + + public ReceivingNotInDeliveryException(ErrorCodeIfs errorCodeIfs, Throwable throwable) { + super(throwable); + this.errorCodeIfs = errorCodeIfs; + this.description = errorCodeIfs.getDescription(); + } + + public ReceivingNotInDeliveryException(ErrorCodeIfs errorCodeIfs, Throwable throwable, + String errorDescription) { + super(throwable); + this.errorCodeIfs = errorCodeIfs; + this.description = errorDescription; + } + +} \ No newline at end of file diff --git a/delivery/src/main/java/delivery/domain/receiving/business/ReceivingBusiness.java b/delivery/src/main/java/delivery/domain/receiving/business/ReceivingBusiness.java index ba5de09d..8133f524 100644 --- a/delivery/src/main/java/delivery/domain/receiving/business/ReceivingBusiness.java +++ b/delivery/src/main/java/delivery/domain/receiving/business/ReceivingBusiness.java @@ -136,4 +136,19 @@ public ReceivingResponse deliveryStart(Long requestId) { return receivingResponse; } + + public ReceivingResponse deliveryComplete(Long requestId) { + + ReceivingEntity receivingEntity = receivingService.getRequestBy(requestId); + + if (receivingEntity.getStatus() != ReceivingStatus.DELIVERY) { + throw new ReceivingNotInConfirmationException( + ReceivingErrorCode.RECEIVING_NOT_IN_CONFIRMATION); + } + + ReceivingEntity updateEntity = receivingService.deliveryComplete(receivingEntity); + + return setGoodsIdAndUserNameReceivingResponse(updateEntity); + + } } diff --git a/delivery/src/main/java/delivery/domain/receiving/controller/ReceivingApiController.java b/delivery/src/main/java/delivery/domain/receiving/controller/ReceivingApiController.java index 4a55433f..b27d8ab6 100644 --- a/delivery/src/main/java/delivery/domain/receiving/controller/ReceivingApiController.java +++ b/delivery/src/main/java/delivery/domain/receiving/controller/ReceivingApiController.java @@ -57,4 +57,11 @@ public Api deliveryStart(@PathVariable Long requestId) { return Api.OK(response); } + // TODO Login DeliveryMan 정보 활용 필요 + @PostMapping("/complete/{requestId}") + public Api deliveryComplete(@PathVariable Long requestId) { + ReceivingResponse response = receivingBusiness.deliveryComplete(requestId); + return Api.OK(response); + } + } diff --git a/delivery/src/main/java/delivery/domain/receiving/service/ReceivingService.java b/delivery/src/main/java/delivery/domain/receiving/service/ReceivingService.java index 46add192..1ea57597 100644 --- a/delivery/src/main/java/delivery/domain/receiving/service/ReceivingService.java +++ b/delivery/src/main/java/delivery/domain/receiving/service/ReceivingService.java @@ -62,4 +62,9 @@ public ReceivingEntity startDelivery(ReceivingEntity receivingEntity) { receivingEntity.setStatus(ReceivingStatus.DELIVERY); return receivingRepository.save(receivingEntity); } + + public ReceivingEntity deliveryComplete(ReceivingEntity receivingEntity) { + receivingEntity.setStatus(ReceivingStatus.RECEIVING); + return receivingRepository.save(receivingEntity); + } } From c2e002bbd9f58dbc92a8f75f74b4a6fd99066612 Mon Sep 17 00:00:00 2001 From: shinyeongwoon Date: Tue, 20 Aug 2024 18:41:38 +0900 Subject: [PATCH 07/12] =?UTF-8?q?SB-275=20(feat)=20:=20=EC=B6=9C=EA=B3=A0?= =?UTF-8?q?=20=EB=B0=B0=EC=86=A1=20=EC=99=84=EB=A3=8C=20=EA=B8=B0=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SB-275 (feat) : 출고 배송 완료 기능 1. 출고 배송 완료 기능 1-1. 출고 요청서 상태 배송중 > 배송 완료 전환 - Controller, Business, Service 구현 1-2. 물품 상태 출고 중 -> 출고 전환 - GoodsService 구현 2. ShippingNotInDeliveryException 구현 - Exception, ExceptionHandler, ErrorCode 추가 --- .../common/error/ShippingErrorCode.java | 1 + .../exception/ShippingExceptionHandler.java | 8 +++++ .../ShippingNotInDeliveryException.java | 34 +++++++++++++++++++ .../domain/goods/service/GoodsService.java | 12 ++++++- .../shipping/business/ShippingBusiness.java | 22 ++++++++++++ .../controller/ShippingApiController.java | 6 ++++ .../shipping/service/ShippingService.java | 5 +++ 7 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 delivery/src/main/java/delivery/common/exception/shipping/ShippingNotInDeliveryException.java diff --git a/delivery/src/main/java/delivery/common/error/ShippingErrorCode.java b/delivery/src/main/java/delivery/common/error/ShippingErrorCode.java index d51fd106..7fd6b288 100644 --- a/delivery/src/main/java/delivery/common/error/ShippingErrorCode.java +++ b/delivery/src/main/java/delivery/common/error/ShippingErrorCode.java @@ -12,6 +12,7 @@ public enum ShippingErrorCode implements ErrorCodeIfs { SHIPPING_REQUEST_NOT_FOUND(HttpStatus.NOT_FOUND.value(), 1500, "출고 요청서가 존재하지 않습니다."), SHIPPING_NOT_IN_PENDING(HttpStatus.NOT_FOUND.value(),1501,"출고 요청 상태가 아닙니다."), SHIPPING_NOT_IN_REGISTERED(HttpStatus.NOT_FOUND.value(),1502,"출고 접수 상태가 아닙니다."), + SHIPPING_NOT_IN_DELIVERY(HttpStatus.NOT_FOUND.value(),1503,"출고 배송 상태가 아닙니다."), ; private final Integer httpCode; diff --git a/delivery/src/main/java/delivery/common/exception/ShippingExceptionHandler.java b/delivery/src/main/java/delivery/common/exception/ShippingExceptionHandler.java index d0c94d95..7cdc1060 100644 --- a/delivery/src/main/java/delivery/common/exception/ShippingExceptionHandler.java +++ b/delivery/src/main/java/delivery/common/exception/ShippingExceptionHandler.java @@ -2,6 +2,7 @@ import delivery.common.error.ShippingErrorCode; import delivery.common.exception.shipping.ShippingNotFoundException; +import delivery.common.exception.shipping.ShippingNotInDeliveryException; import delivery.common.exception.shipping.ShippingNotInPendingException; import delivery.common.exception.shipping.ShippingNotInRegisteredException; import global.api.Api; @@ -36,4 +37,11 @@ public ResponseEntity> shippingNotInRegisteredException(ShippingNotI .body(Api.ERROR(ShippingErrorCode.SHIPPING_NOT_IN_REGISTERED)); } + @ExceptionHandler(value = ShippingNotInDeliveryException.class) + public ResponseEntity> shippingNotInDeliveryException(ShippingNotInDeliveryException e) { + log.info("", e); + return ResponseEntity.status(HttpStatus.NOT_FOUND) + .body(Api.ERROR(ShippingErrorCode.SHIPPING_NOT_IN_DELIVERY)); + } + } diff --git a/delivery/src/main/java/delivery/common/exception/shipping/ShippingNotInDeliveryException.java b/delivery/src/main/java/delivery/common/exception/shipping/ShippingNotInDeliveryException.java new file mode 100644 index 00000000..be334966 --- /dev/null +++ b/delivery/src/main/java/delivery/common/exception/shipping/ShippingNotInDeliveryException.java @@ -0,0 +1,34 @@ +package delivery.common.exception.shipping; + +import global.errorcode.ErrorCodeIfs; + +public class ShippingNotInDeliveryException extends RuntimeException { + + private final ErrorCodeIfs errorCodeIfs; + private final String description; + + public ShippingNotInDeliveryException(ErrorCodeIfs errorCodeIfs) { + super(errorCodeIfs.getDescription()); + this.errorCodeIfs = errorCodeIfs; + this.description = errorCodeIfs.getDescription(); + } + + public ShippingNotInDeliveryException(ErrorCodeIfs errorCodeIfs, String errorDescription) { + this.errorCodeIfs = errorCodeIfs; + this.description = errorDescription; + } + + public ShippingNotInDeliveryException(ErrorCodeIfs errorCodeIfs, Throwable throwable) { + super(throwable); + this.errorCodeIfs = errorCodeIfs; + this.description = errorCodeIfs.getDescription(); + } + + public ShippingNotInDeliveryException(ErrorCodeIfs errorCodeIfs, Throwable throwable, + String errorDescription) { + super(throwable); + this.errorCodeIfs = errorCodeIfs; + this.description = errorDescription; + } + +} \ No newline at end of file diff --git a/delivery/src/main/java/delivery/domain/goods/service/GoodsService.java b/delivery/src/main/java/delivery/domain/goods/service/GoodsService.java index f7a4b6be..9f269574 100644 --- a/delivery/src/main/java/delivery/domain/goods/service/GoodsService.java +++ b/delivery/src/main/java/delivery/domain/goods/service/GoodsService.java @@ -5,8 +5,8 @@ import db.domain.goods.enums.GoodsStatus; import delivery.common.error.GoodsErrorCode; import delivery.common.exception.goods.GoodsNotFoundException; +import delivery.common.exception.goods.GoodsNotInShippingIngException; import java.util.List; -import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -33,4 +33,14 @@ public GoodsEntity startShipping(GoodsEntity goodsEntity) { goodsEntity.setStatus(GoodsStatus.SHIPPING_ING); return goodsRepository.save(goodsEntity); } + + public GoodsEntity changeShippingComplete(GoodsEntity goodsEntity) { + + if (goodsEntity.getStatus() != GoodsStatus.SHIPPING_ING){ + throw new GoodsNotInShippingIngException(GoodsErrorCode.GOODS_NOT_IN_SHIPPING_ING); + } + + goodsEntity.setStatus(GoodsStatus.SHIPPING); + return goodsRepository.save(goodsEntity); + } } diff --git a/delivery/src/main/java/delivery/domain/shipping/business/ShippingBusiness.java b/delivery/src/main/java/delivery/domain/shipping/business/ShippingBusiness.java index ea9e4b55..67bc8047 100644 --- a/delivery/src/main/java/delivery/domain/shipping/business/ShippingBusiness.java +++ b/delivery/src/main/java/delivery/domain/shipping/business/ShippingBusiness.java @@ -139,4 +139,26 @@ public ShippingResponse deliveryStart(Long requestId) { return shippingResponse; } + + public ShippingResponse deliveryComplete(Long requestId) { + + ShippingEntity shippingEntity = shippingService.getRequest(requestId); + + if (shippingEntity.getStatus() != ShippingStatus.DELIVERY) { + throw new ShippingNotInRegisteredException( + ShippingErrorCode.SHIPPING_NOT_IN_DELIVERY); + } + + ShippingEntity updateEntity = shippingService.deliveryComplete(shippingEntity); + + ShippingResponse shippingResponse = getShippingResponse(updateEntity); + + shippingResponse.getGoodsIdList().forEach(goodsId -> { + GoodsEntity goodsEntity = goodsService.getGoodsBy(goodsId); + goodsService.changeShippingComplete(goodsEntity); + }); + + return shippingResponse; + + } } diff --git a/delivery/src/main/java/delivery/domain/shipping/controller/ShippingApiController.java b/delivery/src/main/java/delivery/domain/shipping/controller/ShippingApiController.java index 4134827e..fab26308 100644 --- a/delivery/src/main/java/delivery/domain/shipping/controller/ShippingApiController.java +++ b/delivery/src/main/java/delivery/domain/shipping/controller/ShippingApiController.java @@ -57,6 +57,12 @@ public Api deliveryStart(@PathVariable Long requestId) { return Api.OK(response); } + // TODO Login DeliveryMan 정보 활용 필요 + @PostMapping("/complete/{requestId}") + public Api deliveryComplete(@PathVariable Long requestId) { + ShippingResponse response = shippingBusiness.deliveryComplete(requestId); + return Api.OK(response); + } } diff --git a/delivery/src/main/java/delivery/domain/shipping/service/ShippingService.java b/delivery/src/main/java/delivery/domain/shipping/service/ShippingService.java index 3b17edf0..fd538528 100644 --- a/delivery/src/main/java/delivery/domain/shipping/service/ShippingService.java +++ b/delivery/src/main/java/delivery/domain/shipping/service/ShippingService.java @@ -66,4 +66,9 @@ public ShippingEntity startDelivery(ShippingEntity shippingEntity) { shippingEntity.setStatus(ShippingStatus.DELIVERY); return shippingRepository.save(shippingEntity); } + + public ShippingEntity deliveryComplete(ShippingEntity shippingEntity) { + shippingEntity.setStatus(ShippingStatus.SHIPPED); + return shippingRepository.save(shippingEntity); + } } From 613a3bbcbd9c2efe098a01bd40a9cda52112cfbb Mon Sep 17 00:00:00 2001 From: shinyeongwoon Date: Wed, 21 Aug 2024 10:04:42 +0900 Subject: [PATCH 08/12] =?UTF-8?q?SB-276=20(feat)=20:=20=EC=9E=85=EA=B3=A0?= =?UTF-8?q?=20=EC=9A=94=EC=B2=AD=EC=84=9C=20=EB=82=B4=20=EB=AC=BC=ED=92=88?= =?UTF-8?q?=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SB-276 (feat) : 입고 요청서 내 물품 목록 조회 1. 입고 요청서 내 물품 목록 조회 기능 구현 - GoodsController, Business, Service, Convert 구현 2. Image Set 구현 - Id, Kind Caption 저장용 객체 구현 - ImageService, Converter 구현 --- .../domain/goods/business/GoodsBusiness.java | 45 +++++++++++++++++++ .../goods/controller/GoodsApiController.java | 27 +++++++++++ .../goods/controller/model/GoodsResponse.java | 37 +++++++++++++++ .../controller/model/GoodsResponses.java | 17 +++++++ .../goods/controller/model/ImageSet.java | 19 ++++++++ .../goods/converter/GoodsConverter.java | 25 +++++++++++ .../domain/goods/service/GoodsService.java | 12 +++++ .../image/converter/ImageConverter.java | 26 +++++++++++ .../domain/image/service/ImageService.java | 19 ++++++++ 9 files changed, 227 insertions(+) create mode 100644 delivery/src/main/java/delivery/domain/goods/business/GoodsBusiness.java create mode 100644 delivery/src/main/java/delivery/domain/goods/controller/GoodsApiController.java create mode 100644 delivery/src/main/java/delivery/domain/goods/controller/model/GoodsResponse.java create mode 100644 delivery/src/main/java/delivery/domain/goods/controller/model/GoodsResponses.java create mode 100644 delivery/src/main/java/delivery/domain/goods/controller/model/ImageSet.java create mode 100644 delivery/src/main/java/delivery/domain/image/converter/ImageConverter.java create mode 100644 delivery/src/main/java/delivery/domain/image/service/ImageService.java diff --git a/delivery/src/main/java/delivery/domain/goods/business/GoodsBusiness.java b/delivery/src/main/java/delivery/domain/goods/business/GoodsBusiness.java new file mode 100644 index 00000000..d0b52354 --- /dev/null +++ b/delivery/src/main/java/delivery/domain/goods/business/GoodsBusiness.java @@ -0,0 +1,45 @@ +package delivery.domain.goods.business; + +import db.domain.goods.GoodsEntity; +import db.domain.image.ImageEntity; +import db.domain.image.ImageRepository; +import delivery.domain.goods.controller.model.GoodsResponses; +import delivery.domain.goods.controller.model.ImageSet; +import delivery.domain.goods.converter.GoodsConverter; +import delivery.domain.goods.service.GoodsService; +import delivery.domain.image.converter.ImageConverter; +import delivery.domain.image.service.ImageService; +import global.annotation.Business; +import java.util.List; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@Business +@RequiredArgsConstructor +public class GoodsBusiness { + + private final GoodsService goodsService; + private final GoodsConverter goodsConverter; + private final ImageService imageService; + private final ImageConverter imageConverter; + private final ImageRepository imageRepository; + + public GoodsResponses getGoodsListBy(Long requestId) { + + List goodsEntityList = goodsService.getGoodsListBy(requestId); + + + GoodsResponses responses = goodsConverter.toResponseList(goodsEntityList); + + responses.getGoodsResponseList().forEach(response -> { + log.info("goods id [{}] : goods Name [{}] ", response.getId(), response.getName()); + // GoodsImage Set Setting + List imageEntityList = imageService.getImageListBy(response.getId()); + List imageSet = imageConverter.toImageSetList(imageEntityList); + response.setImages(imageSet); + }); + + return responses; + } +} diff --git a/delivery/src/main/java/delivery/domain/goods/controller/GoodsApiController.java b/delivery/src/main/java/delivery/domain/goods/controller/GoodsApiController.java new file mode 100644 index 00000000..a1b75219 --- /dev/null +++ b/delivery/src/main/java/delivery/domain/goods/controller/GoodsApiController.java @@ -0,0 +1,27 @@ +package delivery.domain.goods.controller; + +import delivery.domain.goods.business.GoodsBusiness; +import delivery.domain.goods.controller.model.GoodsResponses; +import global.api.Api; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/goods") +public class GoodsApiController { + + private final GoodsBusiness goodsBusiness; + + @GetMapping("/receiving/{requestId}") + public Api receivingGoods( + @PathVariable Long requestId + ){ + GoodsResponses response = goodsBusiness.getGoodsListBy(requestId); + return Api.OK(response); + } + +} diff --git a/delivery/src/main/java/delivery/domain/goods/controller/model/GoodsResponse.java b/delivery/src/main/java/delivery/domain/goods/controller/model/GoodsResponse.java new file mode 100644 index 00000000..f15fcf22 --- /dev/null +++ b/delivery/src/main/java/delivery/domain/goods/controller/model/GoodsResponse.java @@ -0,0 +1,37 @@ +package delivery.domain.goods.controller.model; + +import db.domain.goods.enums.GoodsCategory; +import db.domain.goods.enums.GoodsStatus; +import jakarta.persistence.Column; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import java.time.LocalDateTime; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class GoodsResponse { + + private Long id; + + private String name; + + private String modelName; + + private GoodsCategory category; + + private int quantity; + + private LocalDateTime abandonmentAt; + + private GoodsStatus status; + + private List images; + +} diff --git a/delivery/src/main/java/delivery/domain/goods/controller/model/GoodsResponses.java b/delivery/src/main/java/delivery/domain/goods/controller/model/GoodsResponses.java new file mode 100644 index 00000000..e8c50ccc --- /dev/null +++ b/delivery/src/main/java/delivery/domain/goods/controller/model/GoodsResponses.java @@ -0,0 +1,17 @@ +package delivery.domain.goods.controller.model; + +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class GoodsResponses { + + List goodsResponseList; + +} diff --git a/delivery/src/main/java/delivery/domain/goods/controller/model/ImageSet.java b/delivery/src/main/java/delivery/domain/goods/controller/model/ImageSet.java new file mode 100644 index 00000000..60090535 --- /dev/null +++ b/delivery/src/main/java/delivery/domain/goods/controller/model/ImageSet.java @@ -0,0 +1,19 @@ +package delivery.domain.goods.controller.model; + +import db.domain.image.enums.ImageKind; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ImageSet { + + private Long imageId; + private String caption; + private ImageKind kind; + +} diff --git a/delivery/src/main/java/delivery/domain/goods/converter/GoodsConverter.java b/delivery/src/main/java/delivery/domain/goods/converter/GoodsConverter.java index e9ae98ed..04fcbe3c 100644 --- a/delivery/src/main/java/delivery/domain/goods/converter/GoodsConverter.java +++ b/delivery/src/main/java/delivery/domain/goods/converter/GoodsConverter.java @@ -1,8 +1,33 @@ package delivery.domain.goods.converter; +import db.domain.goods.GoodsEntity; +import delivery.domain.goods.controller.model.GoodsResponse; +import delivery.domain.goods.controller.model.GoodsResponses; import global.annotation.Converter; +import java.util.List; @Converter public class GoodsConverter { + public GoodsResponses toResponseList(List goodsEntityList) { + List goodsResponses = goodsEntityList.stream().map(goodsEntity -> { + return toResponse(goodsEntity); + }).toList(); + return GoodsResponses.builder() + .goodsResponseList(goodsResponses) + .build(); + } + + public GoodsResponse toResponse(GoodsEntity goodsEntity) { + return GoodsResponse.builder() + .id(goodsEntity.getId()) + .name(goodsEntity.getName()) + .modelName(goodsEntity.getModelName()) + .status(goodsEntity.getStatus()) + .quantity(goodsEntity.getQuantity()) + .category(goodsEntity.getCategory()) + .abandonmentAt(goodsEntity.getAbandonmentAt()) + .build(); + } + } diff --git a/delivery/src/main/java/delivery/domain/goods/service/GoodsService.java b/delivery/src/main/java/delivery/domain/goods/service/GoodsService.java index 9f269574..0ad270fa 100644 --- a/delivery/src/main/java/delivery/domain/goods/service/GoodsService.java +++ b/delivery/src/main/java/delivery/domain/goods/service/GoodsService.java @@ -43,4 +43,16 @@ public GoodsEntity changeShippingComplete(GoodsEntity goodsEntity) { goodsEntity.setStatus(GoodsStatus.SHIPPING); return goodsRepository.save(goodsEntity); } + + public List getGoodsListBy(Long requestId) { + + List goodsEntityList = goodsRepository.findAllByReceivingIdOrderByIdDesc( + requestId); + + if (goodsEntityList.isEmpty()){ + throw new GoodsNotFoundException(GoodsErrorCode.GOODS_NOT_FOUND); + } + + return goodsEntityList; + } } diff --git a/delivery/src/main/java/delivery/domain/image/converter/ImageConverter.java b/delivery/src/main/java/delivery/domain/image/converter/ImageConverter.java new file mode 100644 index 00000000..4c34a92a --- /dev/null +++ b/delivery/src/main/java/delivery/domain/image/converter/ImageConverter.java @@ -0,0 +1,26 @@ +package delivery.domain.image.converter; + +import db.domain.image.ImageEntity; +import delivery.domain.goods.controller.model.ImageSet; +import global.annotation.Converter; +import java.util.List; + +@Converter +public class ImageConverter { + + public List toImageSetList(List imageEntityList) { + return imageEntityList.stream().map(imageEntity -> { + return toImageSet(imageEntity); + }).toList(); + } + + public ImageSet toImageSet(ImageEntity imageEntity) { + return ImageSet.builder() + .imageId(imageEntity.getId()) + .caption(imageEntity.getCaption()) + .kind(imageEntity.getKind()) + .build(); + } + + +} diff --git a/delivery/src/main/java/delivery/domain/image/service/ImageService.java b/delivery/src/main/java/delivery/domain/image/service/ImageService.java new file mode 100644 index 00000000..544b9e9f --- /dev/null +++ b/delivery/src/main/java/delivery/domain/image/service/ImageService.java @@ -0,0 +1,19 @@ +package delivery.domain.image.service; + +import db.domain.image.ImageEntity; +import db.domain.image.ImageRepository; +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class ImageService { + + private final ImageRepository imageRepository; + + public List getImageListBy(Long imageId) { + return imageRepository.findAllByGoodsIdOrderByIdDesc(imageId); + } + +} From 78859d03266d3a2fbfb8a8b471fedb4b3bcc2090 Mon Sep 17 00:00:00 2001 From: shinyeongwoon Date: Wed, 21 Aug 2024 10:24:07 +0900 Subject: [PATCH 09/12] =?UTF-8?q?SB-277=20(feat)=20:=20=EC=B6=9C=EA=B3=A0?= =?UTF-8?q?=20=EC=9A=94=EC=B2=AD=EC=84=9C=20=EB=82=B4=20=EB=AC=BC=ED=92=88?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SB-277 (feat) : 출고 요청서 내 물품 조회 1. 출고 요청서 내 물품 조회 기능 구현 - Controller, Business, Service 구현 --- .../domain/goods/business/GoodsBusiness.java | 14 ++++++++++++-- .../goods/controller/GoodsApiController.java | 10 +++++++++- .../domain/goods/service/GoodsService.java | 11 ----------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/delivery/src/main/java/delivery/domain/goods/business/GoodsBusiness.java b/delivery/src/main/java/delivery/domain/goods/business/GoodsBusiness.java index d0b52354..a7cc0eb8 100644 --- a/delivery/src/main/java/delivery/domain/goods/business/GoodsBusiness.java +++ b/delivery/src/main/java/delivery/domain/goods/business/GoodsBusiness.java @@ -25,11 +25,21 @@ public class GoodsBusiness { private final ImageConverter imageConverter; private final ImageRepository imageRepository; - public GoodsResponses getGoodsListBy(Long requestId) { + public GoodsResponses getReceivingGoodsListBy(Long requestId) { - List goodsEntityList = goodsService.getGoodsListBy(requestId); + List goodsEntityList = goodsService.getReceivingGoodsList(requestId); + return setImageSet(goodsEntityList); + } + + public GoodsResponses getShippingGoodsListBy(Long requestId) { + + List goodsEntityList = goodsService.getShippingGoodsList(requestId); + + return setImageSet(goodsEntityList); + } + private GoodsResponses setImageSet(List goodsEntityList) { GoodsResponses responses = goodsConverter.toResponseList(goodsEntityList); responses.getGoodsResponseList().forEach(response -> { diff --git a/delivery/src/main/java/delivery/domain/goods/controller/GoodsApiController.java b/delivery/src/main/java/delivery/domain/goods/controller/GoodsApiController.java index a1b75219..bba5d18d 100644 --- a/delivery/src/main/java/delivery/domain/goods/controller/GoodsApiController.java +++ b/delivery/src/main/java/delivery/domain/goods/controller/GoodsApiController.java @@ -20,7 +20,15 @@ public class GoodsApiController { public Api receivingGoods( @PathVariable Long requestId ){ - GoodsResponses response = goodsBusiness.getGoodsListBy(requestId); + GoodsResponses response = goodsBusiness.getReceivingGoodsListBy(requestId); + return Api.OK(response); + } + + @GetMapping("/shipping/{requestId}") + public Api shippingGoods( + @PathVariable Long requestId + ){ + GoodsResponses response = goodsBusiness.getShippingGoodsListBy(requestId); return Api.OK(response); } diff --git a/delivery/src/main/java/delivery/domain/goods/service/GoodsService.java b/delivery/src/main/java/delivery/domain/goods/service/GoodsService.java index 0ad270fa..86fc5d96 100644 --- a/delivery/src/main/java/delivery/domain/goods/service/GoodsService.java +++ b/delivery/src/main/java/delivery/domain/goods/service/GoodsService.java @@ -44,15 +44,4 @@ public GoodsEntity changeShippingComplete(GoodsEntity goodsEntity) { return goodsRepository.save(goodsEntity); } - public List getGoodsListBy(Long requestId) { - - List goodsEntityList = goodsRepository.findAllByReceivingIdOrderByIdDesc( - requestId); - - if (goodsEntityList.isEmpty()){ - throw new GoodsNotFoundException(GoodsErrorCode.GOODS_NOT_FOUND); - } - - return goodsEntityList; - } } From acd9ec5a1fe62a2a21ee52de1b52de9a70fc3731 Mon Sep 17 00:00:00 2001 From: shinyeongwoon Date: Wed, 21 Aug 2024 10:38:56 +0900 Subject: [PATCH 10/12] =?UTF-8?q?SB-278=20(feat)=20:=20=EB=AC=BC=ED=92=88?= =?UTF-8?q?=20=EC=83=81=EC=84=B8=EB=B3=B4=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=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-278 (feat) : 물품 상세보기 기능 구현 1. 물품 상세보기 기능 구현 - Controller, Business 구현 --- .../delivery/domain/goods/business/GoodsBusiness.java | 10 ++++++++++ .../domain/goods/controller/GoodsApiController.java | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/delivery/src/main/java/delivery/domain/goods/business/GoodsBusiness.java b/delivery/src/main/java/delivery/domain/goods/business/GoodsBusiness.java index a7cc0eb8..1d908664 100644 --- a/delivery/src/main/java/delivery/domain/goods/business/GoodsBusiness.java +++ b/delivery/src/main/java/delivery/domain/goods/business/GoodsBusiness.java @@ -3,6 +3,7 @@ import db.domain.goods.GoodsEntity; import db.domain.image.ImageEntity; import db.domain.image.ImageRepository; +import delivery.domain.goods.controller.model.GoodsResponse; import delivery.domain.goods.controller.model.GoodsResponses; import delivery.domain.goods.controller.model.ImageSet; import delivery.domain.goods.converter.GoodsConverter; @@ -52,4 +53,13 @@ private GoodsResponses setImageSet(List goodsEntityList) { return responses; } + + public GoodsResponse getGoodsBy(Long goodsId) { + GoodsEntity goodsEntity = goodsService.getGoodsBy(goodsId); + GoodsResponse response = goodsConverter.toResponse(goodsEntity); + List imageEntityList = imageService.getImageListBy(response.getId()); + List imageSet = imageConverter.toImageSetList(imageEntityList); + response.setImages(imageSet); + return response; + } } diff --git a/delivery/src/main/java/delivery/domain/goods/controller/GoodsApiController.java b/delivery/src/main/java/delivery/domain/goods/controller/GoodsApiController.java index bba5d18d..875abaef 100644 --- a/delivery/src/main/java/delivery/domain/goods/controller/GoodsApiController.java +++ b/delivery/src/main/java/delivery/domain/goods/controller/GoodsApiController.java @@ -1,6 +1,7 @@ package delivery.domain.goods.controller; import delivery.domain.goods.business.GoodsBusiness; +import delivery.domain.goods.controller.model.GoodsResponse; import delivery.domain.goods.controller.model.GoodsResponses; import global.api.Api; import lombok.RequiredArgsConstructor; @@ -32,4 +33,10 @@ public Api shippingGoods( return Api.OK(response); } + @GetMapping("/{goodsId}") + public Api goodsById(@PathVariable Long goodsId){ + GoodsResponse response = goodsBusiness.getGoodsBy(goodsId); + return Api.OK(response); + } + } From d0506b876549765413c1a2040b2228f7a33dbd28 Mon Sep 17 00:00:00 2001 From: SEOB Date: Wed, 21 Aug 2024 13:51:20 +0900 Subject: [PATCH 11/12] =?UTF-8?q?SB-279=20(!HOTFIX)=20:=20=EB=B9=84?= =?UTF-8?q?=EB=B0=80=EB=B2=88=ED=98=B8=20Pattern=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SB-279 (!HOTFIX) : 비밀번호 Pattern 오류 수정 1. UsersRegisterRequest - #, ~ 문자도 허용하도록 수정 --- .../users/controller/model/register/UsersRegisterRequest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/warehouse/src/main/java/warehouse/domain/users/controller/model/register/UsersRegisterRequest.java b/warehouse/src/main/java/warehouse/domain/users/controller/model/register/UsersRegisterRequest.java index 40962cad..43f69868 100644 --- a/warehouse/src/main/java/warehouse/domain/users/controller/model/register/UsersRegisterRequest.java +++ b/warehouse/src/main/java/warehouse/domain/users/controller/model/register/UsersRegisterRequest.java @@ -18,7 +18,7 @@ public class UsersRegisterRequest { @Pattern(regexp = "^[0-9a-zA-Z]{1,50}@[0-9a-zA-Z]{1,24}+(\\.[0-9a-zA-Z]+){1,24}$") private String email; - @Pattern(regexp = "^(?=.*[A-Z])(?=.*[a-z])(?=.*[^a-zA-Z0-9])(?!.*[\\\\{}()<>#$%^&*_=|~`]).{8,100}$") + @Pattern(regexp = "^(?=.*[A-Z])(?=.*[a-z])(?=.*[^a-zA-Z0-9])(?!.*[\\\\{}()<>$%^&*_=|`]).{8,100}$") private String password; @Pattern(regexp = "^[가-힣]{1,50}$") From cbcbbeb91464b97726b26f580e76c8aa3b7b999a Mon Sep 17 00:00:00 2001 From: SEOB Date: Wed, 21 Aug 2024 14:54:11 +0900 Subject: [PATCH 12/12] =?UTF-8?q?SB-280=20(!HOTFIX)=20:=20=EB=AC=BC?= =?UTF-8?q?=ED=92=88=20=EC=83=81=ED=83=9C=EB=A1=9C=20=EB=AC=BC=ED=92=88=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EC=86=8C?= =?UTF-8?q?=EC=9C=A0=EC=9E=90=20=EA=B6=8C=ED=95=9C=20=EC=98=88=EC=99=B8=20?= =?UTF-8?q?=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SB-280 (!HOTFIX) : 물품 상태로 물품 목록 조회 시 소유자 권한 예외 버그 수정 원인 : status 로 모든 물품을 가져올 때 사용자를 확인하지 않고 goodsOwnerCheckWithThrow() 메서드를 호출하여 예외가 터짐 해결 : status 와 userId 로 물품 조회하도록 변경 1. GoodsBusiness - goodsOwnerCheckWithThrow() 메서드 제거 2. GoodsRepository - findAllByStatusAndUserIdOrderByIdDesc() 로 변경 3. GoodsService - 파라미터 변경 --- .../java/db/domain/goods/GoodsRepository.java | 2 +- .../domain/goods/business/GoodsBusiness.java | 19 ++++++------------- .../domain/goods/service/GoodsService.java | 4 ++-- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/db/src/main/java/db/domain/goods/GoodsRepository.java b/db/src/main/java/db/domain/goods/GoodsRepository.java index 0ba4bd3b..66f23efc 100644 --- a/db/src/main/java/db/domain/goods/GoodsRepository.java +++ b/db/src/main/java/db/domain/goods/GoodsRepository.java @@ -13,7 +13,7 @@ public interface GoodsRepository extends JpaRepository { List findAllByIdIn(List goodsIdList); - List findAllByStatusOrderByIdDesc(GoodsStatus status); + List findAllByStatusAndUserIdOrderByIdDesc(GoodsStatus status, Long userId); List findAllByTakeBackIdOrderByIdDesc(Long takeBackId); 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 069373fe..fe43a53a 100644 --- a/warehouse/src/main/java/warehouse/domain/goods/business/GoodsBusiness.java +++ b/warehouse/src/main/java/warehouse/domain/goods/business/GoodsBusiness.java @@ -46,25 +46,25 @@ public List getGoodsList(GetGoodsStrategy strategy, Long requestI List goodsList = findGoodsListById(strategy, requestId, email); - return getGoodsResponsesBy(goodsList, email); + return getGoodsResponsesBy(goodsList); } @Transactional public List getGoodsList(GoodsStatus status, String email) { - List goodsList = goodsService.findAllByGoodsStatusWithThrow(status); + Long userId = usersService.getUserWithThrow(email).getId(); - return getGoodsResponsesBy(goodsList, email); + List goodsList = goodsService.findAllByGoodsStatusAndUserIdWithThrow(status ,userId); + + return getGoodsResponsesBy(goodsList); } - private List getGoodsResponsesBy(List goodsList, String email) { + private List getGoodsResponsesBy(List goodsList) { List goodsResponse = new ArrayList<>(); goodsList.forEach(goodsEntity -> { - goodsOwnerCheckWithThrow(email, goodsEntity); - ImageListResponse imageListResponse = imageConverter.toImageListResponse(goodsEntity); goodsResponse.add(goodsConverter.toResponse(goodsEntity, imageListResponse)); @@ -74,13 +74,6 @@ private List getGoodsResponsesBy(List goodsList, Str return goodsResponse; } - private void goodsOwnerCheckWithThrow(String email, GoodsEntity goodsEntity) { - UserEntity userEntity = usersService.getUserWithThrow(email); - if (!Objects.equals(userEntity.getId(), goodsEntity.getUserId())) { - throw new NotOwnerException(GoodsErrorCode.NOT_OWNER); - } - } - private List findGoodsListById(GetGoodsStrategy strategy, Long requestId, String email) { switch (strategy) { 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 ca7ef9c9..7ac19d4c 100644 --- a/warehouse/src/main/java/warehouse/domain/goods/service/GoodsService.java +++ b/warehouse/src/main/java/warehouse/domain/goods/service/GoodsService.java @@ -104,8 +104,8 @@ private void setGoodsStatusBy(GoodsStatus status, GoodsEntity goodsEntity) { goodsRepository.save(goodsEntity); } - public List findAllByGoodsStatusWithThrow(GoodsStatus status) { - List goodsEntityList = goodsRepository.findAllByStatusOrderByIdDesc(status); + public List findAllByGoodsStatusAndUserIdWithThrow(GoodsStatus status, Long userId) { + List goodsEntityList = goodsRepository.findAllByStatusAndUserIdOrderByIdDesc(status, userId); checkEmptyGoodsListWithThrow(goodsEntityList); return goodsEntityList; }