Skip to content

Commit

Permalink
[refactor] domain에서 history를 저장하기 때문에 service 레이어에서 history를 저장하는 로직 삭제
Browse files Browse the repository at this point in the history
- history를 저장하는 책임을 도메인에게 넘겨버렸기 때문에 필요가 없어졌습니다.
  • Loading branch information
Hyeon-Uk committed Aug 12, 2024
1 parent 581f4c5 commit ec96339
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import camp.woowak.lab.payaccount.domain.PayAccount;
import camp.woowak.lab.payaccount.domain.PayAccountHistory;
import camp.woowak.lab.payaccount.exception.NotFoundAccountException;
import camp.woowak.lab.payaccount.repository.PayAccountHistoryRepository;
import camp.woowak.lab.payaccount.repository.PayAccountRepository;
import camp.woowak.lab.payaccount.service.command.AccountTransactionCommand;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -15,12 +14,9 @@
@Slf4j
public class PayAccountDepositService {
private final PayAccountRepository payAccountRepository;
private final PayAccountHistoryRepository payAccountHistoryRepository;

public PayAccountDepositService(PayAccountRepository payAccountRepository,
PayAccountHistoryRepository payAccountHistoryRepository) {
public PayAccountDepositService(PayAccountRepository payAccountRepository) {
this.payAccountRepository = payAccountRepository;
this.payAccountHistoryRepository = payAccountHistoryRepository;
}

@Transactional
Expand All @@ -30,7 +26,6 @@ public long depositAccount(AccountTransactionCommand command) {

PayAccountHistory depositHistory = payAccount.deposit(command.amount());
log.info("A deposit of {} has been completed into Account ID {}.", command.amount(), command.payAccountId());
payAccountHistoryRepository.save(depositHistory);

return payAccount.getBalance();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import camp.woowak.lab.payaccount.domain.PayAccount;
import camp.woowak.lab.payaccount.domain.PayAccountHistory;
import camp.woowak.lab.payaccount.exception.NotFoundAccountException;
import camp.woowak.lab.payaccount.repository.PayAccountHistoryRepository;
import camp.woowak.lab.payaccount.repository.PayAccountRepository;
import camp.woowak.lab.payaccount.service.command.AccountTransactionCommand;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -15,12 +14,9 @@
@Slf4j
public class PayAccountWithdrawService {
private final PayAccountRepository payAccountRepository;
private final PayAccountHistoryRepository payAccountHistoryRepository;

public PayAccountWithdrawService(PayAccountRepository payAccountRepository,
PayAccountHistoryRepository payAccountHistoryRepository) {
public PayAccountWithdrawService(PayAccountRepository payAccountRepository) {
this.payAccountRepository = payAccountRepository;
this.payAccountHistoryRepository = payAccountHistoryRepository;
}

@Transactional
Expand All @@ -30,7 +26,6 @@ public long withdrawAccount(AccountTransactionCommand command) {

PayAccountHistory withdrawHistory = payAccount.withdraw(command.amount());
log.info("A withdrawal of {} has been completed from Account ID {}", command.amount(), command.payAccountId());
payAccountHistoryRepository.save(withdrawHistory);

return payAccount.getBalance();
}
Expand Down

0 comments on commit ec96339

Please sign in to comment.