Skip to content

💫 [feature] #114 - 미수령 보상 탭 및 보상 집계 구조 추가 - #116

Merged
yn2511 merged 2 commits into
developfrom
feat/rewards-tab-api
Jul 23, 2026
Merged

yn2511 merged 2 commits into
developfrom
feat/rewards-tab-api

Conversation

@yn2511

@yn2511 yn2511 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

#️⃣ Issue Number

📝 요약(Summary)

  • GET /api/v1/rewards — summary + 미수령 items (Notion 명세)
  • POST /api/v1/rewards/{rewardId}/claim — 개별 수령
  • POST /api/v1/rewards/claim-all — 일괄 수령
  • v1: **일반 미션(MISSION)**만 미수령 목록에 포함 (rewardId = mission_completions.id)
  • 공동 미션은 현재 자동 정산이라 pending에 넣지 않음 (응답 구조는 COMMUNITY_MISSION 확장 가능)
  • 기존 POST /missions/completions/{id}/claim은 유지 (내부 로직 재사용)

📝 리뷰 요청사항

  • CodeRabbit 리뷰 대기 (머지하지 않음)
  • Notion「보상 탭 API」와 필드 정렬 확인

💻 테스트 결과

  • com.zerost.api.reward.* 테스트 통과

Summary by CodeRabbit

  • New Features

    • Added a rewards section showing pending mission rewards and summary totals.
    • Added options to claim individual rewards or all available rewards at once.
    • Added reward details including source, earned date, reward type, quantity, and images.
    • Added clear responses for unavailable, missing, or already claimed rewards.
  • Tests

    • Added coverage for reward summaries, individual claims, bulk claims, and API responses.

GET/POST /api/v1/rewards로 일반 미션 미수령 조회·개별·일괄 수령을 제공한다.
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@yn2511, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 29 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 367ed03f-0727-4111-a7e2-cb26b1137cfa

📥 Commits

Reviewing files that changed from the base of the PR and between 09a85dd and fc45181.

📒 Files selected for processing (2)
  • src/main/kotlin/com/zerost/api/reward/application/RewardQueryService.kt
  • src/test/kotlin/com/zerost/api/reward/application/RewardQueryServiceTest.kt
📝 Walkthrough

Walkthrough

Added reward-tab response models, mission-completion queries for unclaimed rewards, services for individual and bulk claiming, reward HTTP endpoints, and tests covering service mapping and controller behavior.

Changes

Reward management

Layer / File(s) Summary
Reward contracts and retrieval
src/main/kotlin/com/zerost/api/common/exception/ErrorCode.kt, src/main/kotlin/com/zerost/api/mission/domain/MissionCompletionRepository.kt, src/main/kotlin/com/zerost/api/reward/application/RewardQueryService.kt, src/main/kotlin/com/zerost/api/reward/presentation/dto/RewardsResponses.kt, src/test/kotlin/com/zerost/api/reward/application/RewardQueryServiceTest.kt
Defines reward error codes and response DTOs, queries approved unclaimed mission completions, maps them into reward bundles, and computes pending summaries.
Reward claim orchestration
src/main/kotlin/com/zerost/api/reward/application/RewardClaimService.kt
Adds individual and bulk claim operations, delegating claims to mission reward logic and translating mission errors into reward errors.
Reward HTTP endpoints
src/main/kotlin/com/zerost/api/reward/presentation/RewardController.kt, src/test/kotlin/com/zerost/api/reward/presentation/RewardControllerTest.kt
Adds authenticated GET, individual POST, and bulk POST reward endpoints with controller tests for response payloads and service calls.

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

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant RewardController
  participant RewardQueryService
  participant MissionCompletionRepository
  participant RewardClaimService
  participant MissionRewardClaimService

  Client->>RewardController: GET /api/v1/rewards
  RewardController->>RewardQueryService: getRewards(userId)
  RewardQueryService->>MissionCompletionRepository: find approved unclaimed completions
  MissionCompletionRepository-->>RewardQueryService: mission completions
  RewardQueryService-->>RewardController: RewardsTabResponse
  RewardController-->>Client: ApiResponse

  Client->>RewardController: POST /api/v1/rewards/{rewardId}/claim
  RewardController->>RewardClaimService: claimReward(userId, rewardId)
  RewardClaimService->>MissionRewardClaimService: claim mission reward
  MissionRewardClaimService-->>RewardClaimService: claim result or error
  RewardClaimService-->>RewardController: ClaimRewardResponse
  RewardController-->>Client: ApiResponse

  Client->>RewardController: POST /api/v1/rewards/claim-all
  RewardController->>RewardClaimService: claimAll(userId)
  RewardClaimService->>RewardQueryService: listClaimableMissionCompletions(userId)
  RewardQueryService-->>RewardClaimService: claimable completions
  RewardClaimService->>MissionRewardClaimService: claim each reward
  RewardClaimService-->>RewardController: ClaimAllRewardsResponse
  RewardController-->>Client: ApiResponse
Loading

Possibly related PRs

  • team-0st/BE#56: Introduced the authenticated request attribute used by the reward controller.
  • team-0st/BE#97: Added the mission completion claim timestamp and mission claim error behavior used by the reward flow.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding the unclaimed rewards tab and reward aggregation structure.
Description check ✅ Passed The description includes the required issue number, summary, review notes, and test results, and matches the template well.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/rewards-tab-api

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.

Actionable comments posted: 2

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

Inline comments:
In `@src/main/kotlin/com/zerost/api/reward/application/RewardQueryService.kt`:
- Around line 56-59: The MISSION reward bundle currently duplicates the
completion ID in sourceId; update RewardQueryService to use
completion.mission.id for sourceId while keeping rewardId mapped to
completion.id. In
src/main/kotlin/com/zerost/api/reward/application/RewardQueryService.kt lines
56-59, make this mapping change; in
src/test/kotlin/com/zerost/api/reward/application/RewardQueryServiceTest.kt
lines 52-57, assert sourceId equals 1L alongside rewardId equals 55L.
- Around line 43-50: Validate that the user exists before returning bulk-claim
candidates from listClaimableMissionCompletions, or add the same validation at
the start of claimAll. Reuse the existing user-validation mechanism used by
getRewards so unknown users produce the documented 404 instead of an empty
successful response.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 40f07dc7-c72d-412b-a917-ba19619969f6

📥 Commits

Reviewing files that changed from the base of the PR and between d1f4997 and 09a85dd.

📒 Files selected for processing (8)
  • src/main/kotlin/com/zerost/api/common/exception/ErrorCode.kt
  • src/main/kotlin/com/zerost/api/mission/domain/MissionCompletionRepository.kt
  • src/main/kotlin/com/zerost/api/reward/application/RewardClaimService.kt
  • src/main/kotlin/com/zerost/api/reward/application/RewardQueryService.kt
  • src/main/kotlin/com/zerost/api/reward/presentation/RewardController.kt
  • src/main/kotlin/com/zerost/api/reward/presentation/dto/RewardsResponses.kt
  • src/test/kotlin/com/zerost/api/reward/application/RewardQueryServiceTest.kt
  • src/test/kotlin/com/zerost/api/reward/presentation/RewardControllerTest.kt

@yn2511
yn2511 merged commit 4f6ec11 into develop Jul 23, 2026
@yn2511
yn2511 deleted the feat/rewards-tab-api branch July 23, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant