Skip to content

[353] line api#215

Closed
hyeonRS wants to merge 8 commits into
mainfrom
fix/353-line-api
Closed

[353] line api#215
hyeonRS wants to merge 8 commits into
mainfrom
fix/353-line-api

Conversation

@hyeonRS
Copy link
Copy Markdown
Contributor

@hyeonRS hyeonRS commented Mar 13, 2026

개요

  • 개인 임계치 수정 API 요청 데이터 타입 Integer -> Long

관련 BackLog

Resolves: (Backlog Number, ...)

PR 유형

  • [] 새로운 기능 추가
  • 버그 수정
  • CSS 등 사용자 UI 디자인 변경
  • 코드에 영향을 주지 않는 변경사항(오타 수정, 탭 사이즈 변경, 변수명 변경)
  • 코드 리팩토링
  • 주석 추가 및 수정
  • 문서 수정
  • 테스트 추가, 테스트 리팩토링
  • 빌드 부분 혹은 패키지 매니저 수정
  • 파일 혹은 폴더명 수정
  • 파일 혹은 폴더 삭제

PR Checklist

  • 커밋 메시지 컨벤션에 맞게 작성했습니다.
  • 변경 사항에 대한 테스트를 했습니다.(버그 수정/기능에 대한 테스트).

Summary by CodeRabbit

Release Notes

  • New Features

    • Policy update timestamps now included in admin policy responses.
    • Policy change history tracking implemented for create, update, and delete operations.
  • Bug Fixes

    • Adjusted default daily data usage limit to 50 units.

@hyeonRS hyeonRS requested review from hyuuuun and ms-0o0 March 13, 2026 04:51
@hyeonRS hyeonRS self-assigned this Mar 13, 2026
@hyeonRS hyeonRS added bug 버그 관련 priority: low 우선순위: 하 labels Mar 13, 2026
@github-actions
Copy link
Copy Markdown

정책 위반: main에는 dev에서만 PR이 가능합니다. 이 PR은 자동으로 닫습니다.

@github-actions github-actions Bot closed this Mar 13, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 13, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 43e3c09e-1517-48d8-b874-aaf127a565bf

📥 Commits

Reviewing files that changed from the base of the PR and between 7d668e2 and 31f1e71.

📒 Files selected for processing (13)
  • src/main/java/com/pooli/line/domain/dto/request/UpdateIndividualThresholdReqDto.java
  • src/main/java/com/pooli/line/mapper/LineMapper.java
  • src/main/java/com/pooli/policy/domain/dto/response/AdminPolicyActiveResDto.java
  • src/main/java/com/pooli/policy/domain/dto/response/AdminPolicyCateResDto.java
  • src/main/java/com/pooli/policy/domain/dto/response/AdminPolicyResDto.java
  • src/main/java/com/pooli/policy/domain/entity/PolicyHistory.java
  • src/main/java/com/pooli/policy/repository/PolicyHistoryRepository.java
  • src/main/java/com/pooli/policy/service/AdminPolicyServiceImpl.java
  • src/main/java/com/pooli/policy/service/PolicyHistoryService.java
  • src/main/java/com/pooli/policy/service/PolicyHistoryServiceImpl.java
  • src/main/java/com/pooli/policy/service/UserPolicyServiceImpl.java
  • src/test/java/com/pooli/line/service/impl/LineServiceImplTest.java
  • src/test/java/com/pooli/policy/service/UserPolicyServiceImplTest.java

📝 Walkthrough

Walkthrough

This PR introduces policy change history tracking to MongoDB and refactors related code. It migrates individualThreshold from Integer to Long across DTOs and mappers, adds updatedAt fields to response DTOs, creates PolicyHistory entity and repository, implements PolicyHistoryService with recursive diff logic, and integrates history logging throughout service layers.

Changes

Cohort / File(s) Summary
Type Migration for Individual Threshold
src/main/java/com/pooli/line/domain/dto/request/UpdateIndividualThresholdReqDto.java, src/main/java/com/pooli/line/mapper/LineMapper.java, src/test/java/com/pooli/line/service/impl/LineServiceImplTest.java
Changed individualThreshold field type from Integer to Long in DTO and mapper; updated test cases to use long literals.
Response DTO Updates
src/main/java/com/pooli/policy/domain/dto/response/AdminPolicyActiveResDto.java, src/main/java/com/pooli/policy/domain/dto/response/AdminPolicyCateResDto.java, src/main/java/com/pooli/policy/domain/dto/response/AdminPolicyResDto.java
Added updatedAt LocalDateTime field to response DTOs with Swagger schema annotations; AdminPolicyCateResDto added private constructors via Lombok.
MongoDB History Entity & Repository
src/main/java/com/pooli/policy/domain/entity/PolicyHistory.java, src/main/java/com/pooli/policy/repository/PolicyHistoryRepository.java
Introduced new PolicyHistory MongoDB entity with UpdateDetail inner class for capturing before/after states; added MongoRepository interface for persistence.
History Logging Service
src/main/java/com/pooli/policy/service/PolicyHistoryService.java, src/main/java/com/pooli/policy/service/PolicyHistoryServiceImpl.java
Created PolicyHistoryService interface and implementation with recursive diff logic for detecting changes in nested objects, maps, and lists; captures user and timestamp context.
Service Integration
src/main/java/com/pooli/policy/service/AdminPolicyServiceImpl.java, src/main/java/com/pooli/policy/service/UserPolicyServiceImpl.java
Integrated PolicyHistoryService to log CREATE/UPDATE/DELETE events for policies and categories; extended applied policy retrieval to include limitPolicy and appPolicyList; adjusted default maxDailyData from 100L to 50L; replaced in-method responses with DB re-fetches to capture updatedAt.
Test Updates
src/test/java/com/pooli/policy/service/UserPolicyServiceImplTest.java
Added mocks for PolicyHistoryService and ObjectProvider; expanded getAppliedPolicies tests to validate limitPolicy and appPolicyList; adjusted test data and assertion patterns.

Sequence Diagram

sequenceDiagram
    participant Service as AdminPolicyServiceImpl/<br/>UserPolicyServiceImpl
    participant History as PolicyHistoryService
    participant Diff as DiffLogic
    participant Repo as PolicyHistoryRepository
    participant DB as MongoDB

    Service->>Service: Create/Update/Delete Policy
    Service->>History: log(tableName, event, targetId,<br/>before, after)
    History->>History: Retrieve authenticated user
    History->>Diff: calculateDetails(before, after)
    Diff->>Diff: recursiveDiff(before, after)
    Note over Diff: Compare nested objects,<br/>maps, and lists
    Diff-->>History: UpdateDetail with changes
    History->>Repo: save(PolicyHistory)
    Repo->>DB: Persist to MongoDB
    DB-->>Repo: Success
    Repo-->>History: Saved entity
    History-->>Service: Log complete
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • Dev to main #202 — Modifies UserPolicyServiceImpl's app-policy creation/toggle flow; overlaps with main PR's changes to the same code paths for history logging and AppPolicy handling.
  • Feat/180 domain user minsu #26 — Introduces the UpdateIndividualThresholdReqDto and LineMapper method that this PR modifies by changing individualThreshold type from Integer to Long.

Suggested reviewers

  • hyuuuun
  • ms-0o0

Poem

🐰 A threshold grows from small to long,
While histories recorded strong,
MongoDB keeps the tale so true—
Each change is logged, before and new! 📝

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/353-line-api
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

CodeRabbit can enforce grammar and style rules using `languagetool`.

Configure the reviews.tools.languagetool setting to enable/disable rules and categories. Refer to the LanguageTool Community to learn more.

@github-actions
Copy link
Copy Markdown

정책 위반: main에는 dev에서만 PR이 가능합니다. 이 PR은 자동으로 닫습니다.

@ms-0o0 ms-0o0 deleted the fix/353-line-api branch March 13, 2026 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 버그 관련 priority: low 우선순위: 하

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants