-
Notifications
You must be signed in to change notification settings - Fork 1
develop #708
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
develop #708
Changes from all commits
8ca8c78
ad91620
b1a5999
c6ca094
849d899
31ea1b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.process.clash.application.shop.product.exception.exception.badrequest; | ||
|
|
||
| import com.process.clash.application.common.exception.exception.BadRequestException; | ||
| import com.process.clash.application.shop.product.exception.status.ProductStatusCode; | ||
|
|
||
| public class NotAblePurchaseException extends BadRequestException { | ||
| public NotAblePurchaseException() { | ||
| super(ProductStatusCode.NOT_ABLE_PURCHASE); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| import com.process.clash.application.shop.purchase.exception.exception.badrequest.PriceTooLargeException; | ||
| import com.process.clash.application.shop.purchase.port.in.CreatePurchaseUseCase; | ||
| import com.process.clash.application.shop.purchase.port.out.PurchaseRepositoryPort; | ||
| import com.process.clash.application.shop.product.exception.exception.badrequest.NotAblePurchaseException; | ||
| import com.process.clash.application.shop.product.exception.exception.notfound.ProductNotFoundException; | ||
| import com.process.clash.application.shop.product.port.out.ProductRepositoryPort; | ||
| import com.process.clash.application.user.user.exception.exception.notfound.UserNotFoundException; | ||
|
|
@@ -39,6 +40,10 @@ public CreatePurchaseData.Result execute(CreatePurchaseData.Command command) { | |
| Product product = productRepositoryPort.findById(command.productId()) | ||
| .orElseThrow(ProductNotFoundException::new); | ||
|
|
||
| if (!product.isAblePurchase()) { | ||
| throw new NotAblePurchaseException(); | ||
| } | ||
|
Comment on lines
+43
to
+45
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| Long userId = command.actor().id(); | ||
|
|
||
| if (userItemRepositoryPort.existsByUserIdAndProductId(userId, product.id())) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,7 +20,8 @@ public record Product( | |||||||||
| String description, | ||||||||||
| Long popularity, | ||||||||||
| Season season, | ||||||||||
| Boolean isSeasonal | ||||||||||
| Boolean isSeasonal, | ||||||||||
| Boolean isAblePurchase | ||||||||||
|
Comment on lines
+23
to
+24
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
또한,
Suggested change
|
||||||||||
| ) { | ||||||||||
| public Product { | ||||||||||
| if (title == null || title.isBlank()) { | ||||||||||
|
|
@@ -42,7 +43,8 @@ public static Product create( | |||||||||
| Long price, | ||||||||||
| Integer discount, | ||||||||||
| String description, | ||||||||||
| Season season | ||||||||||
| Season season, | ||||||||||
| Boolean isAblePurchase | ||||||||||
| ) { | ||||||||||
| return new Product( | ||||||||||
| null, | ||||||||||
|
|
@@ -57,7 +59,8 @@ public static Product create( | |||||||||
| description, | ||||||||||
| 0L, | ||||||||||
| season, | ||||||||||
| season != null | ||||||||||
| season != null, | ||||||||||
| isAblePurchase != null ? isAblePurchase : true | ||||||||||
| ); | ||||||||||
| } | ||||||||||
|
|
||||||||||
|
|
@@ -69,7 +72,8 @@ public Product update( | |||||||||
| Long price, | ||||||||||
| Integer discount, | ||||||||||
| String description, | ||||||||||
| Season season | ||||||||||
| Season season, | ||||||||||
| Boolean isAblePurchase | ||||||||||
| ) { | ||||||||||
| return new Product( | ||||||||||
| this.id, | ||||||||||
|
|
@@ -84,7 +88,8 @@ public Product update( | |||||||||
| description, | ||||||||||
| this.popularity, | ||||||||||
| season, | ||||||||||
| season != null | ||||||||||
| season != null, | ||||||||||
| isAblePurchase != null ? isAblePurchase : this.isAblePurchase | ||||||||||
| ); | ||||||||||
| } | ||||||||||
|
|
||||||||||
|
|
@@ -103,7 +108,8 @@ public Product increasePopularity() { | |||||||||
| this.description, | ||||||||||
| nextPopularity, | ||||||||||
| this.season, | ||||||||||
| this.isSeasonal | ||||||||||
| this.isSeasonal, | ||||||||||
| this.isAblePurchase | ||||||||||
| ); | ||||||||||
| } | ||||||||||
| } | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| ALTER TABLE products | ||
| ADD COLUMN is_able_purchase BOOLEAN NOT NULL DEFAULT TRUE; | ||
|
|
||
| UPDATE products | ||
| SET is_able_purchase = TRUE; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,7 +147,8 @@ private Product product(Long id, ProductCategory category) { | |
| "desc", | ||
| 0L, | ||
| null, | ||
| false | ||
| false, | ||
| true | ||
| ); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,7 +81,8 @@ private Product product(Long id, ProductCategory category) { | |
| "desc", | ||
| 0L, | ||
| null, | ||
| false | ||
| false, | ||
| true | ||
| ); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,7 +78,8 @@ private Product product(Long id, ProductCategory category) { | |
| "desc", | ||
| 0L, | ||
| null, | ||
| false | ||
| false, | ||
| true | ||
| ); | ||
| } | ||
| } | ||
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.
nullable = false제약 조건이 설정되어 있으므로,Boolean래퍼 타입 대신 기본형boolean을 사용하는 것이 좋습니다. 이는 불필요한 박싱/언박싱을 방지하고null가능성을 차단하여 코드의 안정성을 높여줍니다. (참고: 타입 변경 시 Lombok이 생성하는 Getter 명칭이isAblePurchase()로 변경될 수 있으니 매퍼 코드 확인이 필요합니다.)