refactor: DTO 변환 중복 코드 제거#342
Conversation
- SaveRequestResponseDTO.fromEntity(): fromEntityWithPorts(request, List.of(), List.of()) 위임으로 40줄 중복 빌더 블록 제거 - AdminRequestQueryService.buildResponseDTOs(): RequestQueryService.toResponseDTOs() 위임으로 portRequestRepository/podExternalPortRepository 필드 및 동일 로직 제거
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
This PR refactors request-to-DTO conversion to remove duplicated builder / batch-loading logic by centralizing it in RequestQueryService and reusing SaveRequestResponseDTO.fromEntityWithPorts(...).
Changes:
SaveRequestResponseDTO.fromEntity()now delegates tofromEntityWithPorts(request, List.of(), List.of())to eliminate duplicated builder code.RequestQueryService.toResponseDTOs(...)visibility changed fromprivateto package-private so it can be reused within the service package.AdminRequestQueryServicenow delegates request list DTO building toRequestQueryService.toResponseDTOs(...), removing duplicated repositories and mapping logic.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/main/java/DGU_AI_LAB/admin_be/domain/requests/service/RequestQueryService.java | Exposes the existing batch DTO conversion helper (package-private) for reuse and centralizes port/pod port batch loading. |
| src/main/java/DGU_AI_LAB/admin_be/domain/requests/service/AdminRequestQueryService.java | Removes duplicated batch-loading code and delegates list-to-DTO conversion to RequestQueryService. |
| src/main/java/DGU_AI_LAB/admin_be/domain/requests/dto/response/SaveRequestResponseDTO.java | Removes duplicated DTO builder block by delegating to the shared fromEntityWithPorts(...) method with empty lists. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Closes #336
SaveRequestResponseDTO.fromEntity():fromEntityWithPorts(request, List.of(), List.of())에 위임하여 40줄 중복 빌더 블록 제거RequestQueryService.toResponseDTOs():private→ package-private으로 변경하여 같은 패키지 내 공유 가능AdminRequestQueryService.buildResponseDTOs():RequestQueryService.toResponseDTOs()에 위임하고 중복 필드(portRequestRepository,podExternalPortRepository) 및 동일 로직 제거Test plan
GET /api/admin/requests— 목록 조회 정상 동작 (portMappings, podExternalPorts 포함)GET /api/admin/requests/new— PENDING 목록 정상 동작POST /api/requests— 신청 생성 응답에 portMappings: [], podExternalPorts: [] 포함 확인