Skip to content

Commit

Permalink
Merge pull request #94 from Team-Daengnyang/fix/#93
Browse files Browse the repository at this point in the history
[FIX] 내 계좌 정보 조회하기 코드 수정
  • Loading branch information
csb9427 authored Aug 28, 2024
2 parents 6d7dc1b + b872c2f commit 56b0861
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,24 @@ public AccountResponse inquireAccount(Long memberId, String userKey) throws Json

// 2. 외부 API를 통해 계좌 정보 조회
Map<String, Object> responseMap = callInquireAccountApi(accountNumber, userKey);
Map<String, Object> recData = (Map<String, Object>) responseMap.get("REC");

String bankCode = (String) recData.get("bankCode");

// 3. 계좌 코드와 매핑된 계좌 이름 가져오기
Optional<AccountCode> optionalAccountCode = accountCodeRepository.findByAccountCode(bankCode);

if (!optionalAccountCode.isPresent()) {
throw new RuntimeException("해당 계좌 코드를 찾을 수 없습니다.");
}

String accountName = optionalAccountCode.get().getAccountName();
String accountColor = optionalAccount.get().getAccountColor();

return AccountResponse.builder()
.accountTitle((String) responseMap.get("accountTitle"))
.accountNumber((String) responseMap.get("accountNumber"))
.accountColor((String) responseMap.get("accountColor"))
.accountTitle(accountName)
.accountNumber(accountNumber)
.accountColor(accountColor)
.build();
}

Expand Down Expand Up @@ -295,12 +308,13 @@ public AccountInfoResponse getAccountInfo(Long memberId, String userKey) throws

// 2. 외부 API를 통해 계좌 잔액 조회
Map<String, Object> responseMap = callInquireAccountBalanceApi(accountNumber, userKey);
Map<String, Object> recData = (Map<String, Object>) responseMap.get("REC");

int accountBalance = Integer.parseInt((String) responseMap.get("accountBalance"));
String accountCode = (String) responseMap.get("accountCode");
String accountBalance = recData.get("accountBalance").toString();
String bankCode = (String) recData.get("bankCode");

// 3. 계좌 코드와 매핑된 계좌 이름 가져오기
Optional<AccountCode> optionalAccountCode = accountCodeRepository.findByAccountCode(accountCode);
Optional<AccountCode> optionalAccountCode = accountCodeRepository.findByAccountCode(bankCode);

if (!optionalAccountCode.isPresent()) {
throw new RuntimeException("해당 계좌 코드를 찾을 수 없습니다.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
@Data
@Builder
public class AccountInfoResponse {
private String accountTitle;
private String accountNumber;
private int accountBalance;
private String accountBalance;
private String bankName;
}

0 comments on commit 56b0861

Please sign in to comment.