Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] 장바구니 상품 추가 Dto 클래스 타입 record로 변경 및 ErrorCode 추가 #32

Merged
merged 5 commits into from
Sep 8, 2023

Conversation

pdohyung
Copy link
Member

@pdohyung pdohyung commented Sep 8, 2023

💡 연관된 이슈

close #23

📝 작업 내용

  • 기존 장바구니 상품 추가 Dto 클래스를 record 타입으로 수정
  • 장바구니, 상품을 못 찾았을 때 반환하는 ErrorCode 추가

💬 리뷰 요구 사항

@pdohyung pdohyung added the 🔨 Refactor 코드 리팩토링 label Sep 8, 2023
Copy link
Member

@kyeong-hyeok kyeong-hyeok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋습니다 도형씨.

@@ -24,7 +22,6 @@ public class CartController {
private final CartService cartService;

@PostMapping("/add")
@ResponseStatus(HttpStatus.NO_CONTENT)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋습니다.

@@ -37,7 +39,7 @@ public class CartService {
public void addCartItem(CartItemAddRequestDto cartItemAddRequestDto, String userId) {

Member findMember = memberRepository.findByUserId(userId)
.orElseThrow(() -> new IllegalArgumentException("존재하지 않는 회원입니다."));
.orElseThrow(() -> new BusinessException(ErrorCode.MEMBER_NOT_FOUND));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋아요.

@@ -53,16 +55,11 @@ public void addCartItem(CartItemAddRequestDto cartItemAddRequestDto, String user

// 해당 회원의 장바구니를 가져와서 상품을 추가
Cart findCart = cartRepository.findCartByMember_Id(memberId)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 설정은 PhysicalNamingStrategyStandardImpl 이거라 Repository 메서드도 findByMemberId로 바꾸면 될 듯!? 크게 상관은 없긴 하지만 통일한다면~~

(참고)
SpringPhysicalNamingStrategy(Default)
-> camel case를 underscore 형태로 변경
PhysicalNamingStrategyStandardImpl
-> 변수 이름을 그대로 사용

.cart(cart)
.item(item)
.count(count)
.build();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@pdohyung pdohyung merged commit 940fee2 into develop Sep 8, 2023
1 check passed
@pdohyung pdohyung deleted the refactor/23-refactor-cart-add-item-api branch September 8, 2023 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 Refactor 코드 리팩토링
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Refactor] 장바구니 상품 추가 Dto 클래스 타입 record로 변경 및 ErrorCode 추가
2 participants