Skip to content

[FEATURE/#41] 가계부 API 배치 처리 로직 구현#67

Open
hodoon wants to merge 12 commits intodevelopfrom
feat/ledger
Open

[FEATURE/#41] 가계부 API 배치 처리 로직 구현#67
hodoon wants to merge 12 commits intodevelopfrom
feat/ledger

Conversation

@hodoon
Copy link
Collaborator

@hodoon hodoon commented Feb 1, 2026

🔗 Related Issue

📝 Summary

  • 가계부 API 배치 처리 로직 구현

🔄 Changes

  • 리팩토링

💬 Questions & Review Points

  • LedgerEntryJdbcRepository에 있는 sql확인 부탁 드립니다~

📸 API Test Results (Swagger)

image

✅ Checklist

  • API 테스트 완료
  • 테스트 결과 사진 첨부
  • 빌드 성공 확인 (./gradlew build)

@hodoon hodoon self-assigned this Feb 1, 2026
@hodoon hodoon added ✨ feat 기능 구현 도훈 도훈 labels Feb 1, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello @hodoon, 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!

이 PR은 사용자의 금융 거래 내역을 통합 관리하는 가계부 기능을 전면적으로 도입합니다. 은행 및 카드 거래 데이터를 자동으로 수집, 분류하고, 중복을 제거하여 LedgerEntry로 저장하는 배치 처리 로직을 핵심으로 합니다. 이를 통해 사용자는 자신의 소비 패턴을 다양한 관점에서 분석하고 시각화할 수 있는 강력한 도구를 제공받게 됩니다.

Highlights

  • 새로운 가계부 모듈 도입: 사용자의 금융 거래 내역을 통합 관리하기 위한 포괄적인 가계부 모듈이 새롭게 추가되었습니다.
  • 거래 내역 동기화 배치 처리: 은행 거래 내역과 카드 승인 내역을 효율적으로 수집하고 LedgerEntry로 저장하는 배치 처리 로직이 구현되었습니다.
  • 자동 카테고리 분류 및 중복 거래 방지: 거래 내역의 키워드를 기반으로 카테고리를 자동으로 분류하며, 은행 및 카드 거래 내역 간의 중복을 정밀하게 감지하고 방지하는 로직이 적용되었습니다.
  • 다양한 가계부 조회 API 제공: 거래 내역 목록, 월별 요약, 카테고리별 통계, 일별 통계, 지출 추이, 최다 소비 항목, 또래 비교 등 사용자의 소비 패턴 분석을 위한 다양한 조회 API가 제공됩니다.

🧠 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.

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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의 배치 처리 로직을 구현하는 것을 목표로 합니다. 전반적으로 JDBC batchUpdate를 사용한 대량 데이터 처리, 중복 데이터 방지를 위한 정교한 매칭 로직 등 좋은 시도들이 보입니다. 코드 리뷰에서는 주로 데이터 처리 로직의 정확성, 성능 최적화, 코드의 일관성 및 가독성 개선에 중점을 두었습니다. 몇 가지 제안 사항은 다음과 같습니다:

  • 카드 결제 취소 거래 유형을 INCOME 대신 REFUND로 명확히 하여 금액 계산 오류를 수정
  • 동기화 요청 파라미터 검증 로직의 버그 수정
  • 불필요한 데이터베이스 조회 제거를 통한 성능 개선
  • 코드 중복 제거 및 캡슐화 강화
    이러한 부분들을 개선하면 더 안정적이고 효율적인 시스템이 될 것입니다.
I am having trouble creating individual review comments. Click here to see my feedback.

src/main/java/org/umc/valuedi/domain/ledger/service/command/LedgerSyncService.java (83)

high

요청 파라미터 검증 로직에 버그가 있습니다. 현재 로직 (A && B) || CyearMonth가 제공된 경우에도 toDate가 없으면 예외를 발생시킵니다. yearMonth 또는 fromDate 둘 중 하나는 필수로 제공되어야 한다는 의도를 반영하도록 수정하는 것이 좋습니다.

        if (ObjectUtils.isEmpty(request.getYearMonth()) && ObjectUtils.isEmpty(request.getFromDate())) {

src/main/java/org/umc/valuedi/domain/ledger/service/command/LedgerSyncService.java (183)

high

카드 결제 취소 시 transactionTypeINCOME으로 설정하고 있습니다. 이는 개념적으로 혼란을 줄 수 있으며, LedgerQueryRepositorygetCardAmountExpression 메서드에서 지출 계산 시 해당 내역이 누락되는 버그를 유발합니다. TransactionType.REFUND를 사용하여 취소/환불임을 명확히 하고, 관련 계산 로직이 올바르게 동작하도록 수정해야 합니다.

                transactionType = TransactionType.REFUND;

src/main/java/org/umc/valuedi/domain/ledger/controller/LedgerController.java (65)

medium

성공 메시지가 하드코딩되어 있습니다. LedgerSuccessCode에 이미 메시지가 정의되어 있으므로, 이를 활용하여 중복을 제거하고 일관성을 유지하는 것이 좋습니다.

        return ApiResponse.onSuccess(LedgerSuccessCode.LEDGER_SYNC_SUCCESS, LedgerSuccessCode.LEDGER_SYNC_SUCCESS.getMessage());

src/main/java/org/umc/valuedi/domain/ledger/converter/LedgerConverter.java (27-33)

medium

if-else-if 블록은 불필요해 보입니다. type 변수는 이미 24번째 줄에서 entry.getTransactionType()으로 초기화되었고, 이 블록은 같은 값을 다시 할당하고 있습니다. 이 코드를 제거하여 가독성을 높일 수 있습니다.

src/main/java/org/umc/valuedi/domain/ledger/exception/code/LedgerErrorCode.java (14)

medium

오류 메시지에 오타가 있습니다. 닫는 괄호 )가 빠졌습니다.

    INVALID_SYNC_REQUEST(HttpStatus.BAD_REQUEST, "LEDGER400_1","동기화 요청 파라미터가 잘못되었습니다. (yearMonth 또는 fromDate/toDate 필수)"),

src/main/java/org/umc/valuedi/domain/ledger/service/command/LedgerSyncService.java (127)

medium

여기서 syncCardApprovals를 호출하고 있는데, 이 메서드 내부에서 다시 cardApprovalRepository.findByUsedDateBetween(from, to)를 호출하여 데이터베이스 조회를 수행합니다. 이미 121번째 줄에서 필요한 데이터를 버퍼를 포함하여 조회했으므로, 이 데이터를 필터링하여 syncCardApprovals에 전달하면 불필요한 데이터베이스 조회를 줄일 수 있습니다. 성능 향상을 위해 리팩토링을 고려해 보세요.

src/main/java/org/umc/valuedi/domain/ledger/service/command/LedgerSyncService.java (198)

medium

syncBankTransactions 메서드는 이 클래스 내부에서만 사용되므로 private으로 선언하여 캡슐화를 강화하는 것이 좋습니다.

    private void syncBankTransactions(

src/main/java/org/umc/valuedi/domain/ledger/service/query/LedgerQueryService.java (50-54)

medium

서비스 레이어에서 응답 DTO 객체의 상태를 변경하는 것은 부작용을 유발할 수 있어 좋은 설계가 아닐 수 있습니다. CategoryStatResponsepercentage 필드를 설정하기 위해 setter를 사용하고 있는데, DTO를 불변(immutable) 객체로 만들고, 스트림의 map 연산을 사용하여 계산된 percentage를 포함하는 새로운 DTO를 생성하여 반환하는 방식을 고려해 보세요. 이렇게 하면 코드의 예측 가능성과 안정성을 높일 수 있습니다.

Copy link
Collaborator

@JeongGyul JeongGyul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다!

@seamooll seamooll linked an issue Feb 2, 2026 that may be closed by this pull request
4 tasks
Copy link
Collaborator

@lee-si-yeon lee-si-yeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다!

@kkeunii
Copy link
Collaborator

kkeunii commented Feb 3, 2026

고생하셨습니다!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ feat 기능 구현 도훈 도훈

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] 가게부 API 구현

5 participants