Feat/#148 add change request fetch api#149
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds functionality to fetch all change requests regardless of their status, extending the existing change request API. Previously, only pending change requests could be retrieved.
- Adds a new
getAllChangeRequests()method to retrieve change requests in all statuses - Extends the
ChangeRequestResponseDTOto include anadminCommentfield - Creates a new API endpoint
/allfor fetching all change requests
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| AdminRequestQueryService.java | Adds service method to fetch all change requests without status filtering |
| ChangeRequestResponseDTO.java | Extends response DTO to include admin comment field |
| AdminRequestChangeApi.java | Adds API documentation for the new getAllChangeRequests endpoint |
| AdminRequestChangeController.java | Implements new REST endpoint for fetching all change requests |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| public List<ChangeRequestResponseDTO> getAllChangeRequests() { | ||
| return changeRequestRepository.findAll().stream() | ||
| .map(ChangeRequestResponseDTO::fromEntity) | ||
| .collect(Collectors.toList()); | ||
| } |
There was a problem hiding this comment.
The new getAllChangeRequests() method duplicates the logic from the existing getChangeRequests() method. Consider extracting the common stream processing logic into a private helper method to reduce code duplication.
| public List<ChangeRequestResponseDTO> getAllChangeRequests() { | ||
| return changeRequestRepository.findAll().stream() |
There was a problem hiding this comment.
Using findAll() without pagination could lead to performance issues if there are many change requests. Consider adding pagination parameters or implementing a limit to prevent loading excessive data into memory.
| public List<ChangeRequestResponseDTO> getAllChangeRequests() { | |
| return changeRequestRepository.findAll().stream() | |
| public List<ChangeRequestResponseDTO> getAllChangeRequests(int page, int size) { | |
| return changeRequestRepository.findAll(org.springframework.data.domain.PageRequest.of(page, size)) | |
| .stream() |
saokiritoni
left a comment
There was a problem hiding this comment.
수정 사항 한군데? 정도만 고치면 될 거 같습니다! (엔드포인트만) 굿굿 깔끔 ~
| * 모든 변경 요청 목록 조회 (관리자용) | ||
| * 모든 상태의 ChangeRequest 목록을 반환합니다. | ||
| */ | ||
| @GetMapping("/all") |
There was a problem hiding this comment.
/all 말고 될수있으면 그냥 /로만 가는 게 좋을 거 같아요!
| .newValue(changeRequest.getNewValue()) | ||
| .reason(changeRequest.getReason()) | ||
| .status(changeRequest.getStatus()) | ||
| .adminComment(changeRequest.getAdminComment()) |
| .map(ChangeRequestResponseDTO::fromEntity) | ||
| .collect(Collectors.toList()); | ||
| } | ||
|
|
There was a problem hiding this comment.
일단 페이징은 없이가구 제가 시간 되면 공통 페이징 메서드 추가해보겠습니다!
|
|
||
| /** 내 변경 요청 목록 조회 */ | ||
| public List<ChangeRequestResponseDTO> getMyChangeRequests(Long userId) { | ||
| if (!userRepository.existsById(userId)) { |
🌱 관련 이슈