-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/#9/create product table #10
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
base: develop
Are you sure you want to change the base?
Conversation
| // READ: 단건 조회 | ||
| public Product getProduct(Long productid) { | ||
| return productRepository.findById(productid) | ||
| .orElseThrow(() -> new CustomException(ProductErrorStatus._INVALID_PRODUCT)); | ||
| } | ||
|
|
||
| // READ: 전체 조회 | ||
| public List<Product> getProducts() { | ||
| return productRepository.findAll(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
조회 메서드에 @Transactional(readOnly = true)를 명시할 경우 여러 이점이 있습니다!
JPA 관련해서, 코드의 가독성 부분에서,,, 등등
| public void removeStock(int quantity) { | ||
| if (this.stockQuantity < quantity) { | ||
| // 충분한 재고가 없을 경우 예외 처리 | ||
| throw new IllegalArgumentException("재고가 부족합니다."); | ||
| } | ||
| this.stockQuantity -= quantity; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
전역적으로 예외처리를 RestControllerAdvice를 통해 하고 있어, 저희 컨벤션에 맞게 Error코드 추가하고 CustomException을 던지는 방식으로 수정하시면 좋을것 같아요!
✅ PR 유형
🚀 작업 내용
작업한 내용 1
작업한 내용 2
📝️ 관련 이슈
💬 기타 사항 or 추가 코멘트