Skip to content

Conversation

@jj0526
Copy link
Collaborator

@jj0526 jj0526 commented Dec 7, 2025

📌 PR 내용

  • 회비 조회 시 최신 순(id 내림차순)으로 정렬되도록 수정하였습니다

🔍 PR 세부사항

  • UT 결과에 따라 회비 조회 시 최신 순(id 내림차순)으로 정렬되도록 수정하였습니다

📸 관련 스크린샷

  • 일반 경우
{
    "code": 200,
    "message": "회비가 성공적으로 조회되었습니다.",
    "data": {
        "accountId": 1,
        "description": "1기",
        "totalAmount": 10000,
        "currentAmount": 9400,
        "time": "2025-12-07T17:45:05.852681",
        "cardinal": 1,
        "receipts": [
            {
                "id": 3,
                "description": "3번째",
                "source": "3번째입니다",
                "amount": 300,
                "date": "2025-12-01",
                "fileUrls": [
                    {
                        "fileId": 4,
                        "fileName": "파일이름",
                        "fileUrl": "https://image.png"
                    }
                ]
            },
            {
                "id": 2,
                "description": "2번째",
                "source": "2번째입니다",
                "amount": 200,
                "date": "2025-12-01",
                "fileUrls": [
                    {
                        "fileId": 3,
                        "fileName": "파일이름",
                        "fileUrl": "https://image.png"
                    }
                ]
            },
            {
                "id": 1,
                "description": "예시",
                "source": "예시입니다",
                "amount": 100,
                "date": "2025-12-01",
                "fileUrls": [
                    {
                        "fileId": 2,
                        "fileName": "파일이름",
                        "fileUrl": "https://image.png"
                    }
                ]
            }
        ]
    }
}
  • 회비가 없을 경우 빈리스트
{
    "code": 200,
    "message": "회비가 성공적으로 조회되었습니다.",
    "data": {
        "accountId": 2,
        "description": "2기",
        "totalAmount": 1000,
        "currentAmount": 1000,
        "time": "2025-12-07T17:56:38.663915",
        "cardinal": 2,
        "receipts": []
    }
}

📝 주의사항


✅ 체크리스트

  • 리뷰어 설정
  • Assignee 설정
  • Label 설정
  • 제목 양식 맞췄나요? (ex. [WTH-01] PR 템플릿 수정)
  • 변경 사항에 대한 테스트

Summary by CodeRabbit

  • 리팩토링
    • 계정별 영수증 조회 방식이 개선되어 영수증이 생성일 기준 최신순(내림차순)으로 안정적으로 표시됩니다.
    • 영수증 조회 로직이 중앙화되어 일관된 조회 동작과 향상된 응답 안정성 및 로딩 동작 개선이 이루어졌습니다.

✏️ Tip: You can customize this high-level summary in your review settings.

@jj0526 jj0526 requested review from hyxklee and seokjun01 December 7, 2025 08:59
@jj0526 jj0526 self-assigned this Dec 7, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 7, 2025

Walkthrough

영수증 조회를 계정 엔티티 직접 접근에서 ReceiptGetService를 통한 서비스 호출로 변경하고, 리포지토리에 계정별 영수증을 생성일자 내림차순으로 반환하는 조회 메서드를 추가했습니다.

Changes

응집단 / 파일(s) 변경 요약
영수증 저장소 계층
src/main/java/leets/weeth/domain/account/domain/repository/ReceiptRepository.java
List<Receipt> findAllByAccountIdOrderByCreatedAtDesc(Long accountId) 메서드 시그니처 추가; java.util.List import 추가
영수증 조회 서비스
src/main/java/leets/weeth/domain/account/domain/service/ReceiptGetService.java
public List<Receipt> findAllByAccountId(Long accountId) 공개 메서드 추가; 리포지토리의 findAllByAccountIdOrderByCreatedAtDesc(...)로 위임
계정 유스케이스 구현
src/main/java/leets/weeth/domain/account/application/usecase/AccountUseCaseImpl.java
ReceiptGetService 의존성 추가 및 find 메서드에서 account.getReceipts() 대신 receiptGetService.findAllByAccountId(account.getId())로 영수증 조회 로직 변경; 일부 포맷팅 정리

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Controller
    participant AccountUseCaseImpl
    participant ReceiptGetService
    participant ReceiptRepository
    Controller->>AccountUseCaseImpl: 요청: 계정 상세 조회 (accountId)
    AccountUseCaseImpl->>ReceiptGetService: findAllByAccountId(accountId)
    ReceiptGetService->>ReceiptRepository: findAllByAccountIdOrderByCreatedAtDesc(accountId)
    ReceiptRepository-->>ReceiptGetService: List<Receipt> (생성일자 내림차순)
    ReceiptGetService-->>AccountUseCaseImpl: List<Receipt>
    AccountUseCaseImpl-->>Controller: 계정 상세 응답 (영수증 포함)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • 검토 포인트:
    • ReceiptRepository 메서드 명세(정렬 기준: CreatedAt vs Id)와 DB 쿼리 성능
    • AccountUseCaseImpl 내 트랜잭션/지연 로딩 영향과 예외 처리 경로
    • 테스트 커버리지(서비스 위임 경로 및 정렬 검증)

🐰 영수증 줄 맞추고 폴짝폴짝,
서비스에 맡기니 발걸음 가볍네.
생성일 순으로 한 줄로 세우고,
코드 숲에 햇빛 하나 비추네. 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 변경사항의 핵심을 명확하게 설명하고 있습니다. 'WTH-82 회비 조회시 최신순으로 정렬'은 영수증 목록을 최신순으로 정렬하는 것이라는 주요 변경사항을 정확히 반영합니다.
Description check ✅ Passed PR 설명이 제공된 템플릿 구조를 잘 따르고 있으며, PR 내용, 세부사항, 스크린샷, 체크리스트 등이 완성되어 있습니다.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/WTH-82-Weeth-회비-조회시-최신순으로-정렬

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bbc6456 and aff4b64.

📒 Files selected for processing (2)
  • src/main/java/leets/weeth/domain/account/domain/repository/ReceiptRepository.java (1 hunks)
  • src/main/java/leets/weeth/domain/account/domain/service/ReceiptGetService.java (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/leets/weeth/domain/account/domain/service/ReceiptGetService.java
🔇 Additional comments (2)
src/main/java/leets/weeth/domain/account/domain/repository/ReceiptRepository.java (2)

6-6: LGTM!

메서드 반환 타입을 위해 필요한 표준 import 구문입니다.


9-9: 이전 리뷰 피드백을 잘 반영한 개선입니다.

id 대신 createdAt을 기준으로 정렬하도록 변경하여 이전 리뷰어의 제안을 올바르게 적용했습니다. Receipt 엔티티에서 createdAtBaseEntity@CreatedDate로 정의되어 있으며, accountIdAccount와의 @ManyToOne 관계를 통해 Spring Data JPA가 올바르게 해석합니다. 구현이 정확합니다.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Collaborator

@seokjun01 seokjun01 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 ~ 테스트 회비 데이터 3개가 다 12-01 날짜라 세부 순서는 잘 모르겠지만,
id로 보았을 때 3->2->1 순으로 최신순이라고 판단하면 되겠죠 !?
코드는 이상없어 보입니다~~

import java.util.List;

public interface ReceiptRepository extends JpaRepository<Receipt, Long> {
List<Receipt> findAllByAccountIdOrderByIdDesc(Long accountId);
Copy link
Collaborator

Choose a reason for hiding this comment

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

id도 괜찮긴 하지만, 직관성을 위해서 created_at을 기준으로 정렬하는건 어떨까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

넵 생성 시점이 중요하기에 정렬 기준을 id -> createdAt으로 변경했습니다

@jj0526 jj0526 merged commit b9f2023 into develop Dec 15, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants