Skip to content

[WTH-431] 대시보드 기수 기반으로 변경#87

Merged
hyxklee merged 2 commits into
devfrom
refactor/WTH-431-대시보드-조회-API-기수-기반으로-변경하기
Jul 3, 2026

Hidden character warning

The head ref may contain hidden characters: "refactor/WTH-431-\ub300\uc2dc\ubcf4\ub4dc-\uc870\ud68c-API-\uae30\uc218-\uae30\ubc18\uc73c\ub85c-\ubcc0\uacbd\ud558\uae30"
Merged

[WTH-431] 대시보드 기수 기반으로 변경#87
hyxklee merged 2 commits into
devfrom
refactor/WTH-431-대시보드-조회-API-기수-기반으로-변경하기

Conversation

@hyxklee

@hyxklee hyxklee commented Jul 2, 2026

Copy link
Copy Markdown
Member

📌 Summary

어떤 작업인지 한 줄 요약해 주세요.

대시보드 조회 시 기수를 기반으로 조회하도록 수정했습니다.

📝 Changes

변경사항을 what, why, how로 구분해 작성해 주세요.

What

대시보드 조회 시 accountId가 아닌 기수를 기반으로 조회하도록 수정했습니다.

Why

How

  • 기수 기반으로 전환
  • Active 필터링 추가

📸 Screenshots / Logs

필요시 스크린샷 or 로그를 첨부해주세요.

💡 Reviewer 참고사항

리뷰에 참고할 내용을 작성해주세요.

대시보드에서 조회한 accountId로 타 API들 사용할 때 쓰면 될 것 같아용

✅ Checklist

  • PR 제목 설정 완료 (WTH-123 인증 필터 설정)
  • 테스트 구현 완료
  • 리뷰어 등록 완료
  • 자체 코드 리뷰 완료

Summary by CodeRabbit

  • New Features

    • 계정 대시보드 조회 경로가 계정 번호 대신 장부 순번 기준으로 바뀌었고, 응답에 계정 식별 정보가 추가되었습니다.
  • Bug Fixes

    • 비활성 계정에 대해 회원 공개/비공개 변경, 결제 대상 조회, 거래 조회, 대시보드 조회가 더 이상 진행되지 않도록 개선했습니다.
    • 관리자용 거래 조회에서도 비활성 계정 접근 시 명확한 오류가 반환됩니다.
  • Tests

    • 비활성 계정 관련 예외 처리와 대시보드 조회 시나리오에 대한 테스트가 보강되었습니다.

@hyxklee hyxklee requested review from JIN921 and soo0711 July 2, 2026 07:16
@hyxklee hyxklee self-assigned this Jul 2, 2026
@hyxklee hyxklee added the 🔨 Refactor 코드 구조 개선 및 리팩토링 label Jul 2, 2026
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Account 엔티티에 status 기반 isActive 파생 프로퍼티를 추가하고, 여러 커맨드/쿼리 서비스가 상태 비교 대신 isActive를 검사하여 비활성 계정에 대해 AccountNotActiveException을 던지도록 변경했다. 대시보드 조회는 accountId 대신 clubId+cardinal로 계정을 조회하도록 변경되었고, 응답에 accountId 필드가 추가되었다.

Changes

계정 활성 검증 및 대시보드 조회 변경

Layer / File(s) Summary
Account.isActive 파생 프로퍼티 도입
src/main/kotlin/.../domain/entity/Account.kt
status가 ACTIVE인지 나타내는 isActive Boolean 프로퍼티를 추가하고 showToMembers()의 검증 조건을 이 프로퍼티로 전환.
Command 유스케이스의 활성 검증 전환
ManageAccountPaymentUseCase.kt, ManageAccountTransactionUseCase.kt, ManageAccountUseCase.kt, test/.../ManageAccountUseCaseTest.kt
기존 status 비교를 isActive 기반으로 전환하고, updateMemberVisibility에 비활성 계정 예외 처리를 신규 추가, 관련 테스트 케이스 추가.
결제 대상/거래 조회 서비스의 활성 검증 추가
GetAccountPaymentTargetQueryService.kt, GetAccountTransactionQueryService.kt, test/.../GetAccountPaymentTargetQueryServiceTest.kt, test/.../GetAccountTransactionQueryServiceTest.kt
계정 비활성 시 AccountNotActiveException을 던지도록 검증 로직을 추가하고 DRAFT 상태 시나리오 테스트를 신규 작성.
대시보드 조회 파라미터 변경 및 응답 확장
AccountDashboardResponse.kt, AccountDashboardMapper.kt, GetAccountDashboardQueryService.kt, AccountManageController.kt, test/.../GetAccountDashboardQueryServiceTest.kt
응답에 accountId 필드 추가, 조회를 accountId에서 clubId+cardinal 기반으로 전환, 비활성 계정/미존재 계정 예외 처리 추가, 컨트롤러 경로/파라미터 변경, 테스트 전면 갱신.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AccountManageController
  participant GetAccountDashboardQueryService
  participant AccountRepository
  participant Account

  AccountManageController->>GetAccountDashboardQueryService: getDashboard(clubId, cardinal, userId)
  GetAccountDashboardQueryService->>AccountRepository: findByClubIdAndCardinal(clubId, cardinal)
  AccountRepository-->>GetAccountDashboardQueryService: Account 반환
  GetAccountDashboardQueryService->>Account: validateOwnedBy(userId)
  GetAccountDashboardQueryService->>Account: isActive 확인
  alt 비활성
    GetAccountDashboardQueryService-->>AccountManageController: AccountNotActiveException
  else 활성
    GetAccountDashboardQueryService-->>AccountManageController: AccountDashboardResponse(accountId 포함)
  end
Loading

Possibly related PRs

Suggested reviewers: JIN921, soo0711

Poem

통장 속 숫자들이 콩닥콩닥 뛰던 밤,
isActive 한 줄에 상태가 정리됐죠 🐇
DRAFT엔 문을 닫고, ACTIVE엔 문을 열고
cardinal 따라 장부를 척척 찾아가요
토끼도 흐뭇하게 accountId 도장 쾅! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 기수 기반 대시보드 조회로 바뀐 핵심 변경을 간결하게 요약해 제목이 명확합니다.
Description check ✅ Passed Summary, Changes(What/How), Reviewer 참고사항, Checklist가 있어 템플릿을 대부분 충족합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/WTH-431-대시보드-조회-API-기수-기반으로-변경하기

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/kotlin/com/weeth/domain/account/application/usecase/command/ManageAccountUseCase.kt (1)

24-35: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

비활성 계정 "숨김" 처리까지 차단하는 회귀 가능성

isActive 가드가 visible 분기 이전에 위치해 visible=false(숨김) 요청도 예외로 막습니다. 기존에는 hideFromMembers()에 활성 상태 검증이 없어 비활성 계정도 숨김 처리가 가능했는데, 이제는 아예 시도조차 못 하게 됩니다. 계정이 비활성화된 후 관리자가 노출을 끄려는 정상 시나리오를 막을 수 있습니다.

가드를 visible=true(공개) 분기로 한정하는 것이 의도에 맞아 보입니다.

🐛 제안 수정안
         clubPermissionPolicy.requireAdmin(clubId, userId)
         val account = getAccountWithLock(clubId, accountId)
-        if (!account.isActive) throw AccountNotActiveException()
 
         if (visible) {
+            if (!account.isActive) throw AccountNotActiveException()
             account.showToMembers()
         } else {
             account.hideFromMembers()
         }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/kotlin/com/weeth/domain/account/application/usecase/command/ManageAccountUseCase.kt`
around lines 24 - 35, The active-state guard in ManageAccountUseCase.apply
currently blocks both show and hide paths, but the regression only affects the
hide flow. Move the AccountNotActiveException check so it applies only when
visible is true, and leave the visible=false branch able to call
hideFromMembers() for inactive accounts; use the visible condition in the
ManageAccountUseCase method and keep markModifiedBy(userId) unchanged.
🧹 Nitpick comments (2)
src/main/kotlin/com/weeth/domain/account/application/usecase/command/ManageAccountUseCase.kt (1)

3-3: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

isActive 비활성 검증 로직 3곳 중복

동일한 if (!account.isActive) throw AccountNotActiveException() 패턴이 이 파일 외 GetAccountPaymentTargetQueryService.findPaymentStatus, GetAccountDashboardQueryService.getDashboard에도 그대로 반복됩니다. 공용 확장 함수(예: Account.requireActive())로 추출하면 중복을 줄일 수 있습니다.

Also applies to: 26-26

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/kotlin/com/weeth/domain/account/application/usecase/command/ManageAccountUseCase.kt`
at line 3, The `if (!account.isActive) throw AccountNotActiveException()` check
is duplicated across `ManageAccountUseCase` and the other account services
mentioned in the review. Extract this validation into a shared helper or
extension such as `Account.requireActive()` and replace each inline check in
`ManageAccountUseCase`, `GetAccountPaymentTargetQueryService.findPaymentStatus`,
and `GetAccountDashboardQueryService.getDashboard` with the common method.
src/main/kotlin/com/weeth/domain/account/application/usecase/command/ManageAccountPaymentUseCase.kt (1)

128-136: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

isActive 검증 로직 중복 - 공통화 검토

getActiveAccountWithLock private 함수는 ManageAccountTransactionUseCase.kt(107-117)와 완전히 동일하며, if (!account.isActive) throw AccountNotActiveException() 검증 자체도 GetAccountTransactionQueryService.kt(132), GetAccountDashboardQueryService.kt 등 최소 4~5곳에 반복되고 있습니다. Account 엔티티에 이미 validateOwnedBy(clubId) 같은 도메인 검증 메서드가 존재하므로, 활성 검증도 엔티티/도메인 서비스 메서드(예: account.requireActive()) 또는 공통 리더 컴포넌트로 추출해 각 UseCase/QueryService는 호출만 하도록 정리하는 것을 권장합니다.

♻️ 제안 방향 예시
-    private fun getActiveAccountWithLock(
-        clubId: Long,
-        accountId: Long,
-    ): Account {
-        val account = accountRepository.findByIdWithLock(accountId) ?: throw AccountNotFoundException()
-        account.validateOwnedBy(clubId)
-        if (!account.isActive) throw AccountNotActiveException()
-        return account
-    }
+    private fun getActiveAccountWithLock(
+        clubId: Long,
+        accountId: Long,
+    ): Account {
+        val account = accountRepository.findByIdWithLock(accountId) ?: throw AccountNotFoundException()
+        account.validateOwnedBy(clubId)
+        account.validateActive() // 공통 도메인 검증 메서드로 이동
+        return account
+    }

As per coding guidelines, **/*UseCase.kt: UseCase classes orchestrate only; business rules belong in entities or domain services.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/kotlin/com/weeth/domain/account/application/usecase/command/ManageAccountPaymentUseCase.kt`
around lines 128 - 136, The active-account check is duplicated across multiple
use cases/query services, and
`ManageAccountPaymentUseCase.getActiveAccountWithLock` repeats the same `if
(!account.isActive) throw AccountNotActiveException()` logic seen elsewhere.
Move the “active” business rule into a shared domain-level method on `Account`
such as `requireActive()` or into a common domain service, then update
`getActiveAccountWithLock` and the other duplicated call sites to use that
shared validation instead of inlining the check.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@src/main/kotlin/com/weeth/domain/account/application/usecase/command/ManageAccountUseCase.kt`:
- Around line 24-35: The active-state guard in ManageAccountUseCase.apply
currently blocks both show and hide paths, but the regression only affects the
hide flow. Move the AccountNotActiveException check so it applies only when
visible is true, and leave the visible=false branch able to call
hideFromMembers() for inactive accounts; use the visible condition in the
ManageAccountUseCase method and keep markModifiedBy(userId) unchanged.

---

Nitpick comments:
In
`@src/main/kotlin/com/weeth/domain/account/application/usecase/command/ManageAccountPaymentUseCase.kt`:
- Around line 128-136: The active-account check is duplicated across multiple
use cases/query services, and
`ManageAccountPaymentUseCase.getActiveAccountWithLock` repeats the same `if
(!account.isActive) throw AccountNotActiveException()` logic seen elsewhere.
Move the “active” business rule into a shared domain-level method on `Account`
such as `requireActive()` or into a common domain service, then update
`getActiveAccountWithLock` and the other duplicated call sites to use that
shared validation instead of inlining the check.

In
`@src/main/kotlin/com/weeth/domain/account/application/usecase/command/ManageAccountUseCase.kt`:
- Line 3: The `if (!account.isActive) throw AccountNotActiveException()` check
is duplicated across `ManageAccountUseCase` and the other account services
mentioned in the review. Extract this validation into a shared helper or
extension such as `Account.requireActive()` and replace each inline check in
`ManageAccountUseCase`, `GetAccountPaymentTargetQueryService.findPaymentStatus`,
and `GetAccountDashboardQueryService.getDashboard` with the common method.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: efdbf5c7-72cf-4fd5-a33f-47a83f5bc30b

📥 Commits

Reviewing files that changed from the base of the PR and between 4154607 and e35e6b5.

📒 Files selected for processing (14)
  • src/main/kotlin/com/weeth/domain/account/application/dto/response/AccountDashboardResponse.kt
  • src/main/kotlin/com/weeth/domain/account/application/mapper/AccountDashboardMapper.kt
  • src/main/kotlin/com/weeth/domain/account/application/usecase/command/ManageAccountPaymentUseCase.kt
  • src/main/kotlin/com/weeth/domain/account/application/usecase/command/ManageAccountTransactionUseCase.kt
  • src/main/kotlin/com/weeth/domain/account/application/usecase/command/ManageAccountUseCase.kt
  • src/main/kotlin/com/weeth/domain/account/application/usecase/query/GetAccountDashboardQueryService.kt
  • src/main/kotlin/com/weeth/domain/account/application/usecase/query/GetAccountPaymentTargetQueryService.kt
  • src/main/kotlin/com/weeth/domain/account/application/usecase/query/GetAccountTransactionQueryService.kt
  • src/main/kotlin/com/weeth/domain/account/domain/entity/Account.kt
  • src/main/kotlin/com/weeth/domain/account/presentation/AccountManageController.kt
  • src/test/kotlin/com/weeth/domain/account/application/usecase/command/ManageAccountUseCaseTest.kt
  • src/test/kotlin/com/weeth/domain/account/application/usecase/query/GetAccountDashboardQueryServiceTest.kt
  • src/test/kotlin/com/weeth/domain/account/application/usecase/query/GetAccountPaymentTargetQueryServiceTest.kt
  • src/test/kotlin/com/weeth/domain/account/application/usecase/query/GetAccountTransactionQueryServiceTest.kt

@soo0711 soo0711 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

수고하셨습니다!! 👍

@hyxklee hyxklee merged commit f3cc2ec into dev Jul 3, 2026
2 checks passed
@hyxklee hyxklee deleted the refactor/WTH-431-대시보드-조회-API-기수-기반으로-변경하기 branch July 3, 2026 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 Refactor 코드 구조 개선 및 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants