From 43b0edcf38e92e5ae90a0dc2f66d35d68c8910ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=B5=E1=84=8E=E1=85=A1=E1=86=AB=E1=84=8C?= =?UTF-8?q?=E1=85=B5=E1=86=AB?= Date: Mon, 27 Feb 2023 21:47:54 +0900 Subject: [PATCH 1/4] =?UTF-8?q?fix=20:=20=EC=A3=BC=EB=AC=B8=20=EC=8A=B9?= =?UTF-8?q?=EC=9D=B8=20=EC=A1=B0=ED=9A=8C=EC=8B=9C=EC=97=90=EB=A7=8C=20?= =?UTF-8?q?=EC=A7=80=EC=9B=8C=EC=A7=84=20=EC=9C=A0=EC=A0=80=20=EC=95=88?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EA=B2=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/OrderCustomRepositoryImpl.java | 8 ++++++++ .../condition/AdminTableOrderFilterType.java | 17 ++++++++++++++--- .../condition/FindEventOrdersCondition.java | 4 ++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/repository/OrderCustomRepositoryImpl.java b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/repository/OrderCustomRepositoryImpl.java index 7f31bc64..f2beb9cf 100644 --- a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/repository/OrderCustomRepositoryImpl.java +++ b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/repository/OrderCustomRepositoryImpl.java @@ -10,6 +10,7 @@ import band.gosrock.domain.domains.order.domain.OrderStatus; import band.gosrock.domain.domains.order.repository.condition.FindEventOrdersCondition; import band.gosrock.domain.domains.order.repository.condition.FindMyPageOrderCondition; +import band.gosrock.domain.domains.user.domain.AccountState; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.core.types.dsl.DateTemplate; import com.querydsl.core.types.dsl.Expressions; @@ -73,6 +74,8 @@ public Page findEventOrders(FindEventOrdersCondition condition, Pageable .join(user) .on(user.id.eq(order.userId)) .where( + // 주문 승인 요청 보여질 때만 지워진 유저를 보이게 하지 않습니다. + condition.showDeleteUserExpression(), eqEventId(condition.getEventId()), condition.getOrderStatusFilter(), condition.getSearchStringFilter()) @@ -88,6 +91,7 @@ public Page findEventOrders(FindEventOrdersCondition condition, Pageable .join(user) .on(user.id.eq(order.userId)) .where( + condition.showDeleteUserExpression(), eqEventId(condition.getEventId()), condition.getOrderStatusFilter(), condition.getSearchStringFilter()); @@ -131,4 +135,8 @@ private BooleanExpression openingState(Boolean isShowing) { ? eventEndAtTemplate.after(now) : eventEndAtTemplate.before(now); } + + private BooleanExpression notDeletedUser() { + return user.accountState.ne(AccountState.DELETED); + } } diff --git a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/repository/condition/AdminTableOrderFilterType.java b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/repository/condition/AdminTableOrderFilterType.java index 9cab0c62..bb7504d7 100644 --- a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/repository/condition/AdminTableOrderFilterType.java +++ b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/repository/condition/AdminTableOrderFilterType.java @@ -6,21 +6,32 @@ import static band.gosrock.domain.domains.order.domain.OrderStatus.PENDING_APPROVE; import static band.gosrock.domain.domains.order.domain.OrderStatus.REFUND; import static band.gosrock.domain.domains.order.domain.QOrder.order; +import static band.gosrock.domain.domains.user.domain.QUser.user; +import band.gosrock.domain.domains.user.domain.AccountState; import com.querydsl.core.types.dsl.BooleanExpression; /** 어드민 테이블의 주문 상태 검색 조건 지정을 위함. */ public enum AdminTableOrderFilterType { - APPROVE_WAITING(order.orderStatus.eq(PENDING_APPROVE)), - CONFIRMED(order.orderStatus.in(CONFIRM, APPROVED, CANCELED, REFUND)); + APPROVE_WAITING( + order.orderStatus.eq(PENDING_APPROVE), user.accountState.ne(AccountState.DELETED)), + // 완료된 주문을 가져오는건 지워진 유저도 불러와야한다. + CONFIRMED(order.orderStatus.in(CONFIRM, APPROVED, CANCELED, REFUND), null); private final BooleanExpression expression; + private final BooleanExpression showDeleteUserExpression; - AdminTableOrderFilterType(BooleanExpression expression) { + AdminTableOrderFilterType( + BooleanExpression expression, BooleanExpression showDeleteUserExpression) { this.expression = expression; + this.showDeleteUserExpression = showDeleteUserExpression; } public BooleanExpression getFilter() { return expression; } + + public BooleanExpression showDeleteUserExpression() { + return showDeleteUserExpression; + } } diff --git a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/repository/condition/FindEventOrdersCondition.java b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/repository/condition/FindEventOrdersCondition.java index 31563a77..9b50843c 100644 --- a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/repository/condition/FindEventOrdersCondition.java +++ b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/repository/condition/FindEventOrdersCondition.java @@ -31,6 +31,10 @@ public BooleanExpression getOrderStatusFilter() { return filterType.getFilter(); } + public BooleanExpression showDeleteUserExpression() { + return filterType.showDeleteUserExpression(); + } + public BooleanExpression getSearchStringFilter() { if (searchType == null) return null; return searchType.getContains(searchString); From df5e790eb0d0c97c3722fa3893830992585151de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=B5=E1=84=8E=E1=85=A1=E1=86=AB=E1=84=8C?= =?UTF-8?q?=E1=85=B5=E1=86=AB?= Date: Mon, 27 Feb 2023 21:53:24 +0900 Subject: [PATCH 2/4] =?UTF-8?q?fix=20:=20=EC=A3=BC=EB=AC=B8=20=EC=8A=B9?= =?UTF-8?q?=EC=9D=B8=EA=B0=84=20=EC=9C=A0=EC=A0=80=20=ED=83=88=ED=87=B4?= =?UTF-8?q?=EC=97=AC=EB=B6=80=20=EA=B2=80=EC=A6=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/validator/OrderValidator.java | 19 +++++++++++++++---- ...anNotApproveDeletedUserOrderException.java | 13 +++++++++++++ .../order/exception/OrderErrorCode.java | 3 ++- .../domain/domains/user/domain/User.java | 4 ++++ 4 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/exception/CanNotApproveDeletedUserOrderException.java diff --git a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/domain/validator/OrderValidator.java b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/domain/validator/OrderValidator.java index 65e8dd7b..68dd6993 100644 --- a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/domain/validator/OrderValidator.java +++ b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/domain/validator/OrderValidator.java @@ -9,6 +9,7 @@ import band.gosrock.domain.domains.order.domain.Order; import band.gosrock.domain.domains.order.domain.OrderLineItem; import band.gosrock.domain.domains.order.domain.OrderStatus; +import band.gosrock.domain.domains.order.exception.CanNotApproveDeletedUserOrderException; import band.gosrock.domain.domains.order.exception.CanNotCancelOrderException; import band.gosrock.domain.domains.order.exception.CanNotRefundOrderException; import band.gosrock.domain.domains.order.exception.InvalidOrderException; @@ -24,6 +25,8 @@ import band.gosrock.domain.domains.ticket_item.adaptor.TicketItemAdaptor; import band.gosrock.domain.domains.ticket_item.domain.Option; import band.gosrock.domain.domains.ticket_item.domain.TicketItem; +import band.gosrock.domain.domains.user.adaptor.UserAdaptor; +import band.gosrock.domain.domains.user.domain.User; import java.util.List; import java.util.Objects; import lombok.RequiredArgsConstructor; @@ -42,6 +45,8 @@ public class OrderValidator { private final IssuedTicketAdaptor issuedTicketAdaptor; private final OptionAdaptor optionAdaptor; + private final UserAdaptor userAdaptor; + /** 주문을 생성할 수 있는지에 대한검증 */ public void validCanCreate(Order order) { TicketItem item = getItem(order); @@ -74,16 +79,22 @@ public void validOptionNotChange(Order order, TicketItem item) { }); } - public void validOptionNotChangeAfterDoneOrderEvent(Order order) { - TicketItem item = getItem(order); - validOptionNotChange(order, item); - } /** 승인 가능한 주문인지 검증합니다. */ public void validCanApproveOrder(Order order) { validMethodIsCanApprove(order); validStatusCanApprove(getOrderStatus(order)); validCanDone(order); + // 유저가 탈퇴를 안했는지 확인. + validUserNotDeleted(order); + } + + /** 주문 승인 간에 유저가 탈퇴를 했는지 조회합니다. */ + private void validUserNotDeleted(Order order) { + User user = userAdaptor.queryUser(order.getUserId()); + if(user.isDeletedUser()){ + throw CanNotApproveDeletedUserOrderException.EXCEPTION; + } } /** 결제 방식의 주문을 승인할수있는지 확인합니다. */ diff --git a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/exception/CanNotApproveDeletedUserOrderException.java b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/exception/CanNotApproveDeletedUserOrderException.java new file mode 100644 index 00000000..f8df1332 --- /dev/null +++ b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/exception/CanNotApproveDeletedUserOrderException.java @@ -0,0 +1,13 @@ +package band.gosrock.domain.domains.order.exception; + + +import band.gosrock.common.exception.DuDoongCodeException; + +public class CanNotApproveDeletedUserOrderException extends DuDoongCodeException { + + public static final DuDoongCodeException EXCEPTION = new CanNotApproveDeletedUserOrderException(); + + private CanNotApproveDeletedUserOrderException() { + super(OrderErrorCode.CAN_NOT_DELETED_USER_APPROVE); + } +} diff --git a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/exception/OrderErrorCode.java b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/exception/OrderErrorCode.java index 1a4a9597..453d57d8 100644 --- a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/exception/OrderErrorCode.java +++ b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/exception/OrderErrorCode.java @@ -34,7 +34,8 @@ public enum OrderErrorCode implements BaseErrorCode { ORDER_LESS_THAN_MINIMUM(BAD_REQUEST, "Order_400_11", "최소 결제금액인 1000원보다 낮은 주문입니다."), @ExplainError("한 장바구니엔 관련된 한 아이템만 올수 있음") ORDER_INVALID_ITEM_KIND_POLICY(BAD_REQUEST, "Order_400_12", "장바구니에 아이템을 담는 정책을 위반하였습니다."), - ORDER_OPTION_CHANGED(BAD_REQUEST, "Order_400_13", "주문 과정중 아이템의 옵션이 변화했습니다."); + ORDER_OPTION_CHANGED(BAD_REQUEST, "Order_400_13", "주문 과정중 아이템의 옵션이 변화했습니다."), + CAN_NOT_DELETED_USER_APPROVE(BAD_REQUEST, "Order_400_14", "유저가 탈퇴를 했습니다."); private Integer status; private String code; diff --git a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/user/domain/User.java b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/user/domain/User.java index 591a5786..4b3b3e36 100644 --- a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/user/domain/User.java +++ b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/user/domain/User.java @@ -126,4 +126,8 @@ public void toggleReceiveEmail() { public void toggleMarketingAgree() { marketingAgree = !marketingAgree; } + + public Boolean isDeletedUser(){ + return accountState == AccountState.DELETED; + } } From ee9493f767f173a2262dbb2269f508b19b134a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=B5=E1=84=8E=E1=85=A1=E1=86=AB=E1=84=8C?= =?UTF-8?q?=E1=85=B5=E1=86=AB?= Date: Mon, 27 Feb 2023 21:53:39 +0900 Subject: [PATCH 3/4] style : spotless --- .../domain/domains/order/domain/validator/OrderValidator.java | 3 +-- .../exception/CanNotApproveDeletedUserOrderException.java | 3 ++- .../java/band/gosrock/domain/domains/user/domain/User.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/domain/validator/OrderValidator.java b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/domain/validator/OrderValidator.java index 68dd6993..89f2394c 100644 --- a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/domain/validator/OrderValidator.java +++ b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/domain/validator/OrderValidator.java @@ -79,7 +79,6 @@ public void validOptionNotChange(Order order, TicketItem item) { }); } - /** 승인 가능한 주문인지 검증합니다. */ public void validCanApproveOrder(Order order) { validMethodIsCanApprove(order); @@ -92,7 +91,7 @@ public void validCanApproveOrder(Order order) { /** 주문 승인 간에 유저가 탈퇴를 했는지 조회합니다. */ private void validUserNotDeleted(Order order) { User user = userAdaptor.queryUser(order.getUserId()); - if(user.isDeletedUser()){ + if (user.isDeletedUser()) { throw CanNotApproveDeletedUserOrderException.EXCEPTION; } } diff --git a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/exception/CanNotApproveDeletedUserOrderException.java b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/exception/CanNotApproveDeletedUserOrderException.java index f8df1332..9ac8214f 100644 --- a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/exception/CanNotApproveDeletedUserOrderException.java +++ b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/exception/CanNotApproveDeletedUserOrderException.java @@ -5,7 +5,8 @@ public class CanNotApproveDeletedUserOrderException extends DuDoongCodeException { - public static final DuDoongCodeException EXCEPTION = new CanNotApproveDeletedUserOrderException(); + public static final DuDoongCodeException EXCEPTION = + new CanNotApproveDeletedUserOrderException(); private CanNotApproveDeletedUserOrderException() { super(OrderErrorCode.CAN_NOT_DELETED_USER_APPROVE); diff --git a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/user/domain/User.java b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/user/domain/User.java index 4b3b3e36..bf7e82fc 100644 --- a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/user/domain/User.java +++ b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/user/domain/User.java @@ -127,7 +127,7 @@ public void toggleMarketingAgree() { marketingAgree = !marketingAgree; } - public Boolean isDeletedUser(){ + public Boolean isDeletedUser() { return accountState == AccountState.DELETED; } } From 51fd3a383480e69551ae63a1eaa40972140fea03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=B5=E1=84=8E=E1=85=A1=E1=86=AB=E1=84=8C?= =?UTF-8?q?=E1=85=B5=E1=86=AB?= Date: Mon, 27 Feb 2023 22:03:00 +0900 Subject: [PATCH 4/4] =?UTF-8?q?test=20:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EB=8F=8C=EC=95=84=EA=B0=80=EA=B2=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domains/order/domain/validator/OrderValidator.java | 2 +- .../order/domain/validator/OrderValidatorTest.java | 8 +++++++- .../service/OrderApproveServiceConcurrencyFailTest.java | 1 + .../order/service/OrderApproveServiceConcurrencyTest.java | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/domain/validator/OrderValidator.java b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/domain/validator/OrderValidator.java index 89f2394c..423d9af2 100644 --- a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/domain/validator/OrderValidator.java +++ b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/domain/validator/OrderValidator.java @@ -89,7 +89,7 @@ public void validCanApproveOrder(Order order) { } /** 주문 승인 간에 유저가 탈퇴를 했는지 조회합니다. */ - private void validUserNotDeleted(Order order) { + public void validUserNotDeleted(Order order) { User user = userAdaptor.queryUser(order.getUserId()); if (user.isDeletedUser()) { throw CanNotApproveDeletedUserOrderException.EXCEPTION; diff --git a/DuDoong-Domain/src/test/java/band/gosrock/domain/domains/order/domain/validator/OrderValidatorTest.java b/DuDoong-Domain/src/test/java/band/gosrock/domain/domains/order/domain/validator/OrderValidatorTest.java index 12c7ec67..fa4616eb 100644 --- a/DuDoong-Domain/src/test/java/band/gosrock/domain/domains/order/domain/validator/OrderValidatorTest.java +++ b/DuDoong-Domain/src/test/java/band/gosrock/domain/domains/order/domain/validator/OrderValidatorTest.java @@ -34,6 +34,7 @@ import band.gosrock.domain.domains.ticket_item.domain.TicketItem; import band.gosrock.domain.domains.ticket_item.exception.TicketItemQuantityLackException; import band.gosrock.domain.domains.ticket_item.exception.TicketPurchaseLimitException; +import band.gosrock.domain.domains.user.adaptor.UserAdaptor; import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.BeforeEach; @@ -55,6 +56,7 @@ class OrderValidatorTest { @Mock TicketItemAdaptor ticketItemAdaptor; @Mock IssuedTicketAdaptor issuedTicketAdaptor; @Mock OptionAdaptor optionAdaptor; + @Mock UserAdaptor userAdaptor; @Mock Option optionOfGroup1; @Mock Option optionOfGroup2; @Mock OrderLineItem orderLineItem; @@ -67,7 +69,11 @@ class OrderValidatorTest { void setUp() { orderValidator = new OrderValidator( - eventAdaptor, ticketItemAdaptor, issuedTicketAdaptor, optionAdaptor); + eventAdaptor, + ticketItemAdaptor, + issuedTicketAdaptor, + optionAdaptor, + userAdaptor); } @Test diff --git a/DuDoong-Domain/src/test/java/band/gosrock/domain/domains/order/service/OrderApproveServiceConcurrencyFailTest.java b/DuDoong-Domain/src/test/java/band/gosrock/domain/domains/order/service/OrderApproveServiceConcurrencyFailTest.java index b3f31db5..905b7099 100644 --- a/DuDoong-Domain/src/test/java/band/gosrock/domain/domains/order/service/OrderApproveServiceConcurrencyFailTest.java +++ b/DuDoong-Domain/src/test/java/band/gosrock/domain/domains/order/service/OrderApproveServiceConcurrencyFailTest.java @@ -52,6 +52,7 @@ void setUp() { .build(); order.addUUID(); willDoNothing().given(orderValidator).validCanDone(any()); + willDoNothing().given(orderValidator).validUserNotDeleted(any()); willCallRealMethod().given(orderValidator).validCanApproveOrder(any()); willCallRealMethod().given(orderValidator).validStatusCanApprove(any()); given(orderAdaptor.findByOrderUuid(any())).willReturn(order); diff --git a/DuDoong-Domain/src/test/java/band/gosrock/domain/domains/order/service/OrderApproveServiceConcurrencyTest.java b/DuDoong-Domain/src/test/java/band/gosrock/domain/domains/order/service/OrderApproveServiceConcurrencyTest.java index 989b6dab..94f94b4e 100644 --- a/DuDoong-Domain/src/test/java/band/gosrock/domain/domains/order/service/OrderApproveServiceConcurrencyTest.java +++ b/DuDoong-Domain/src/test/java/band/gosrock/domain/domains/order/service/OrderApproveServiceConcurrencyTest.java @@ -53,6 +53,7 @@ void setUp() { .build(); order.addUUID(); willDoNothing().given(orderValidator).validCanDone(any()); + willDoNothing().given(orderValidator).validUserNotDeleted(any()); willCallRealMethod().given(orderValidator).validCanApproveOrder(any()); willCallRealMethod().given(orderValidator).validStatusCanApprove(any()); given(orderAdaptor.findByOrderUuid(any())).willReturn(order);