-
Notifications
You must be signed in to change notification settings - Fork 0
[REFACTOR/#94] 카드사 연동 로직 리팩토링 및 CODEF 로깅 시스템 보완 #100
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
base: main
Are you sure you want to change the base?
Conversation
…o ref/#94-card-sync
Summary of ChangesHello @seamooll, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 Pull Request는 카드사 연동 로직의 전반적인 성능, 안정성 및 리소스 관리 효율성을 개선하기 위한 리팩토링을 포함합니다. 외부 API 호출과 데이터베이스 트랜잭션을 명확히 분리하고, 외부 서비스 연동 시 발생할 수 있는 지연 및 오류에 대비하여 타임아웃 설정을 강화했습니다. 또한, 비동기 작업의 안정적인 종료를 보장하고, 시스템 전반의 로깅을 보완하여 운영 및 디버깅 편의성을 향상시켰습니다. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
이번 PR은 외부 API 호출과 데이터베이스 트랜잭션을 분리하여 애플리케이션의 성능과 안정성을 크게 향상시키는 훌륭한 리팩토링입니다. 비동기 작업에 대한 Graceful Shutdown 도입과 타임아웃 설정 강화 또한 운영 안정성을 높이는 좋은 개선입니다. 전반적으로 로깅이 개선되어 관측 가능성도 높아졌습니다. 리뷰 중 런타임에 예외를 발생시킬 수 있는 치명적인 문제 하나와, 코드 일관성 및 설계를 개선할 수 있는 몇 가지 제안 사항을 발견했습니다.
src/main/java/org/umc/valuedi/global/external/codef/service/CodefAssetService.java
Show resolved
Hide resolved
| @Transactional(propagation = Propagation.REQUIRES_NEW) | ||
| public void saveBankAccounts(List<BankAccount> accounts) { | ||
| if (accounts.isEmpty()) return; | ||
| try { | ||
| bankAccountRepository.saveAll(accounts); | ||
| } catch (DataIntegrityViolationException e) { | ||
| for (BankAccount account : accounts) { | ||
| try { | ||
| bankAccountRepository.save(account); | ||
| } catch (DataIntegrityViolationException ex) { | ||
| // 이미 존재하는 계좌는 무시 | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // 전체 승인 내역 조회 (API) | ||
| // CodefAssetService 내부에서 CodefAssetConverter를 통해 매칭까지 완료된 리스트 반환 | ||
| List<CardApproval> approvals = codefAssetService.getCardApprovals(connection); | ||
| if (approvals.isEmpty()) { | ||
| log.info("조회된 승인내역이 없습니다."); | ||
| return false; | ||
| @Transactional(propagation = Propagation.REQUIRES_NEW) | ||
| public void saveBankTransactions(List<BankTransaction> transactions) { | ||
| bankTransactionRepository.bulkInsert(transactions); | ||
| } | ||
|
|
||
| @Transactional(propagation = Propagation.REQUIRES_NEW) | ||
| public void saveCards(List<Card> cards) { | ||
| if (cards.isEmpty()) return; | ||
| try { | ||
| cardRepository.saveAll(cards); | ||
| } catch (DataIntegrityViolationException e) { | ||
| for (Card card : cards) { | ||
| try { | ||
| cardRepository.save(card); | ||
| } catch (DataIntegrityViolationException ex) { | ||
| // 이미 존재하는 카드는 무시 | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // 저장 | ||
| @Transactional(propagation = Propagation.REQUIRES_NEW) | ||
| public void saveCardApprovals(List<CardApproval> approvals) { | ||
| cardApprovalRepository.bulkInsert(approvals); | ||
| log.info("카드 승인내역 Bulk Insert 완료 - {}건", approvals.size()); | ||
| return 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.
새로운 트랜잭션을 시작하기 위해 save... 메서드들을 public으로 만들고 @Transactional(propagation = Propagation.REQUIRES_NEW)를 사용한 것은 좋은 접근입니다. 하지만 스프링의 트랜잭션 프록시를 적용하기 위해 메서드를 public으로만 만드는 것은 캡슐화를 해칠 수 있습니다. 이 메서드들이 의도치 않게 다른 서비스에서 호출될 수 있기 때문입니다. 장기적인 유지보수성을 위해 다음과 같은 대안을 고려해볼 수 있습니다.
- 이
save메서드들을 담을 새로운 컴포넌트(예:AssetPersistenceService)를 만듭니다.AssetSyncService는 이 새 컴포넌트를 주입받아 사용합니다. 이것이 가장 깔끔한 접근 방식입니다. AssetSyncService에 자기 자신을 주입하여 프록시 인스턴스를 통해public트랜잭션 메서드를 호출합니다. 이는 흔한 해결 방법이지만 코드가 혼란스러워질 수 있습니다.
현재 구현도 동작은 하지만, 더 나은 캡슐화를 위해 리팩토링을 권장합니다.
🔗 Related Issue
📝 Summary
🔄 Changes
💬 Questions & Review Points
📸 API Test Results (Swagger)
✅ Checklist