Conversation
feat: not available purchase itmes/#706
There was a problem hiding this comment.
Code Review
This pull request adds an isAblePurchase property to products, enabling administrative control over whether a product can be bought. The changes span the database schema, domain entities, DTOs, and the purchase service, which now validates a product's availability before processing a transaction. Reviewers recommended using primitive boolean types instead of Boolean wrappers in the JPA and domain models to eliminate NullPointerException risks and suggested renaming the field to isPurchasable for improved clarity.
| if (!product.isAblePurchase()) { | ||
| throw new NotAblePurchaseException(); | ||
| } |
| Boolean isSeasonal, | ||
| Boolean isAblePurchase |
There was a problem hiding this comment.
isSeasonal과 isAblePurchase 필드는 null을 허용하지 않는 논리 값이므로, Boolean 래퍼 타입 대신 기본형 boolean을 사용하는 것이 안전합니다. Boolean 타입을 사용하면 CreatePurchaseService 등에서 조건문으로 평가할 때 null인 경우 NullPointerException이 발생할 위험이 있습니다.
또한, isAblePurchase라는 명칭은 상품이 구매를 '행하는' 주체인 것처럼 오해를 불러일으킬 수 있습니다. 상품이 '구매 가능한' 상태임을 나타내는 isPurchasable 또는 purchasable과 같은 명칭이 더 자연스럽습니다.
| Boolean isSeasonal, | |
| Boolean isAblePurchase | |
| boolean isSeasonal, | |
| boolean isAblePurchase |
| @Column(nullable = false, columnDefinition = "BOOLEAN DEFAULT TRUE") | ||
| private Boolean isAblePurchase; |
There was a problem hiding this comment.
nullable = false 제약 조건이 설정되어 있으므로, Boolean 래퍼 타입 대신 기본형 boolean을 사용하는 것이 좋습니다. 이는 불필요한 박싱/언박싱을 방지하고 null 가능성을 차단하여 코드의 안정성을 높여줍니다. (참고: 타입 변경 시 Lombok이 생성하는 Getter 명칭이 isAblePurchase()로 변경될 수 있으니 매퍼 코드 확인이 필요합니다.)
| @Column(nullable = false, columnDefinition = "BOOLEAN DEFAULT TRUE") | |
| private Boolean isAblePurchase; | |
| @Column(nullable = false, columnDefinition = "BOOLEAN DEFAULT TRUE") | |
| private boolean isAblePurchase; |
변경사항
관련 이슈
Closes #
추가 컨텍스트