Skip to content

Commit

Permalink
refactor: 공통 메서드 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
kmebin committed Nov 26, 2023
1 parent abe23c7 commit 96ca221
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/com/moabam/api/application/bug/BugService.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class BugService {
private final PaymentRepository paymentRepository;

public BugResponse getBug(Long memberId) {
Bug bug = memberService.getById(memberId).getBug();
Bug bug = getByMemberId(memberId);

return BugMapper.toBugResponse(bug);
}
Expand All @@ -65,10 +65,14 @@ public PurchaseProductResponse purchaseBugProduct(Long memberId, Long productId,

@Transactional
public void charge(Long memberId, Product bugProduct) {
Bug bug = memberService.getById(memberId).getBug();
Bug bug = getByMemberId(memberId);
bug.charge(bugProduct.getQuantity());
}

private Bug getByMemberId(Long memberId) {
return memberService.getById(memberId).getBug();
}

private Product getById(Long productId) {
return productRepository.findById(productId)
.orElseThrow(() -> new NotFoundException(PRODUCT_NOT_FOUND));
Expand Down

0 comments on commit 96ca221

Please sign in to comment.