Skip to content

Commit de53906

Browse files
committed
Revert "✨ feat: 장바구니 상품 추가/수정 시 데이터 반환하도록 수정"
This reverts commit e875c4f.
1 parent e875c4f commit de53906

File tree

3 files changed

+7
-30
lines changed

3 files changed

+7
-30
lines changed

src/main/java/com/jajaja/domain/cart/controller/CartController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ public ApiResponse<CartResponseDto> getCart(@Auth Long memberId) {
3535
summary = "장바구니 아이템 추가 및 수정 API | by 엠마/신윤지",
3636
description = "장바구니에 아이템을 추가하거나 수량을 수정합니다.")
3737
@PostMapping("/products")
38-
public ApiResponse<CartResponseDto> addOrUpdateCartProduct(@Auth Long memberId, @RequestBody @Valid List<CartProductAddRequestDto> request) {
39-
return ApiResponse.onSuccess(cartCommandService.addOrUpdateCartProduct(memberId, request));
38+
public ApiResponse<String> addOrUpdateCartProduct(@Auth Long memberId, @RequestBody @Valid List<CartProductAddRequestDto> request) {
39+
cartCommandService.addOrUpdateCartProduct(memberId, request);
40+
return ApiResponse.onSuccess("성공적으로 장바구니에 상품이 추가/수정되었습니다.");
4041
}
4142

4243
@Operation(
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package com.jajaja.domain.cart.service;
22

33
import com.jajaja.domain.cart.dto.CartProductAddRequestDto;
4-
import com.jajaja.domain.cart.dto.CartResponseDto;
54

65
import java.util.List;
76

87
public interface CartCommandService {
9-
CartResponseDto addOrUpdateCartProduct(Long memberId, List<CartProductAddRequestDto> request);
8+
void addOrUpdateCartProduct(Long memberId, List<CartProductAddRequestDto> request);
109
void deleteCartProduct(Long memberId, Long productId, Long optionId);
1110
void deleteCartProducts(Long memberId, List<Long> cartProductIds);
1211
}

src/main/java/com/jajaja/domain/cart/service/CartCommandServiceImpl.java

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package com.jajaja.domain.cart.service;
22

3-
import com.jajaja.domain.cart.converter.CartConverter;
43
import com.jajaja.domain.cart.dto.CartProductAddRequestDto;
5-
import com.jajaja.domain.cart.dto.CartProductResponseDto;
6-
import com.jajaja.domain.cart.dto.CartResponseDto;
74
import com.jajaja.domain.cart.entity.Cart;
85
import com.jajaja.domain.cart.entity.CartProduct;
96
import com.jajaja.domain.cart.repository.CartProductRepository;
@@ -14,12 +11,8 @@
1411
import com.jajaja.domain.product.entity.ProductOption;
1512
import com.jajaja.domain.product.repository.ProductOptionRepository;
1613
import com.jajaja.domain.product.repository.ProductRepository;
17-
import com.jajaja.domain.product.service.ProductCommonService;
18-
import com.jajaja.domain.team.entity.enums.TeamStatus;
19-
import com.jajaja.domain.team.repository.TeamCommandRepository;
2014
import com.jajaja.global.apiPayload.code.status.ErrorStatus;
2115
import com.jajaja.global.apiPayload.exception.handler.CartHandler;
22-
import com.jajaja.global.common.dto.PriceInfoDto;
2316
import lombok.RequiredArgsConstructor;
2417
import lombok.extern.slf4j.Slf4j;
2518
import org.springframework.stereotype.Service;
@@ -34,17 +27,15 @@
3427
@Transactional
3528
public class CartCommandServiceImpl implements CartCommandService {
3629

30+
private final CartCommonService cartCommonService;
31+
private final CouponCommonService couponCommonService;
3732
private final CartProductRepository cartProductRepository;
3833
private final ProductRepository productRepository;
39-
private final TeamCommandRepository teamRepository;
4034
private final ProductOptionRepository productOptionRepository;
4135
private final MemberCouponRepository memberCouponRepository;
42-
private final CouponCommonService couponCommonService;
43-
private final ProductCommonService productCommonService;
44-
private final CartCommonService cartCommonService;
4536

4637
@Override
47-
public CartResponseDto addOrUpdateCartProduct(Long memberId, List<CartProductAddRequestDto> request) {
38+
public void addOrUpdateCartProduct(Long memberId, List<CartProductAddRequestDto> request) {
4839
Cart cart = cartCommonService.findCart(memberId);
4940
request.forEach(req -> {
5041
log.info("[CartCommandService] 사용자 {}의 장바구니에 아이템 {} 추가/수정", memberId, req.productId());
@@ -67,21 +58,7 @@ public CartResponseDto addOrUpdateCartProduct(Long memberId, List<CartProductAdd
6758
}
6859
);
6960
});
70-
71-
List<CartProductResponseDto> items = cart.getCartProducts().stream()
72-
.map(cartProduct -> {
73-
boolean isTeamAvailable = teamRepository.existsByProductIdAndStatus(cartProduct.getProduct().getId(), TeamStatus.MATCHING);
74-
return CartProductResponseDto.of(cartProduct, productCommonService.calculateDiscountedPrice(cartProduct.getUnitPrice(), cartProduct.getProduct().getDiscountRate()), isTeamAvailable);
75-
})
76-
.toList();
77-
78-
79-
PriceInfoDto priceInfo = cart.getCoupon() != null ?
80-
couponCommonService.calculateDiscount(cart, cart.getCoupon()) :
81-
PriceInfoDto.noDiscount(cart.calculateTotalAmount());
82-
8361
revalidateAppliedCouponIfExists(cart);
84-
return CartConverter.toCartResponseDto(cart, items, priceInfo);
8562
}
8663

8764
@Override

0 commit comments

Comments
 (0)