Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ public ResponseEntity<SuccessResponse<?>> getChangeRequests() {
return SuccessResponse.ok(changeRequests);
}

/**
* 모든 변경 요청 목록 조회 (관리자용)
* 모든 상태의 ChangeRequest 목록을 반환합니다.
*/
@GetMapping("/all")
Copy link
Member

Choose a reason for hiding this comment

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

/all 말고 될수있으면 그냥 /로만 가는 게 좋을 거 같아요!

public ResponseEntity<SuccessResponse<?>> getAllChangeRequests() {
List<ChangeRequestResponseDTO> changeRequests = adminRequestQueryService.getAllChangeRequests();
return SuccessResponse.ok(changeRequests);
}

@PatchMapping("/approve")
public ResponseEntity<SuccessResponse<?>> approveModification(
@AuthenticationPrincipal(expression = "userId") Long adminId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import DGU_AI_LAB.admin_be.domain.requests.controller.docs.RequestApi;
import DGU_AI_LAB.admin_be.domain.requests.dto.request.SingleChangeRequestDTO;
import DGU_AI_LAB.admin_be.domain.requests.dto.request.SaveRequestRequestDTO;
import DGU_AI_LAB.admin_be.domain.requests.dto.response.ChangeRequestResponseDTO;
import DGU_AI_LAB.admin_be.domain.requests.dto.response.SaveRequestResponseDTO;
import DGU_AI_LAB.admin_be.domain.requests.service.RequestCommandService;
import DGU_AI_LAB.admin_be.domain.requests.service.RequestQueryService;
Expand Down Expand Up @@ -74,4 +75,13 @@ public ResponseEntity<SuccessResponse<?>> getAllFulfilledUsernames() {
List<String> usernames = requestQueryService.getAllFulfilledUsernames();
return SuccessResponse.ok(usernames);
}

/**
* 나의 변경 요청 목록 조회
*/
@GetMapping("/my/changes")
public ResponseEntity<SuccessResponse<?>> getMyChangeRequests(@AuthenticationPrincipal CustomUserDetails user) {
List<ChangeRequestResponseDTO> changeRequests = requestQueryService.getMyChangeRequests(user.getUserId());
return SuccessResponse.ok(changeRequests);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ public interface AdminRequestChangeApi {
})
ResponseEntity<SuccessResponse<?>> getChangeRequests();

@Operation(summary = "모든 변경 요청 목록 조회", description = "모든 상태의 변경 요청 목록을 조회합니다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "성공",
content = @Content(schema = @Schema(implementation = SuccessResponse.class)))
})
ResponseEntity<SuccessResponse<?>> getAllChangeRequests();

@Operation(summary = "변경 요청 승인", description = "PENDING 상태의 변경 요청을 승인하고 설정을 업데이트합니다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "성공",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package DGU_AI_LAB.admin_be.domain.requests.controller.docs;

import DGU_AI_LAB.admin_be.domain.requests.dto.request.SaveRequestRequestDTO;
import DGU_AI_LAB.admin_be.domain.requests.dto.response.ChangeRequestResponseDTO;
import DGU_AI_LAB.admin_be.domain.requests.dto.response.SaveRequestResponseDTO;
import DGU_AI_LAB.admin_be.global.auth.CustomUserDetails;
import DGU_AI_LAB.admin_be.global.common.SuccessResponse;
Expand Down Expand Up @@ -78,4 +79,18 @@ ResponseEntity<SuccessResponse<?>> getMyApprovedRequests(
content = @Content(schema = @Schema(implementation = SuccessResponse.class))
)
ResponseEntity<SuccessResponse<?>> getAllFulfilledUsernames();

@Operation(
summary = "내 변경 요청 목록 조회",
description = "로그인된 사용자가 제출한 모든 변경 요청 내역을 조회합니다. 모든 상태(PENDING, FULFILLED, DENIED)의 변경 요청이 포함됩니다."
)
@ApiResponse(
responseCode = "200",
description = "조회 성공",
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ChangeRequestResponseDTO.class)))
)
ResponseEntity<SuccessResponse<?>> getMyChangeRequests(
@Parameter(hidden = true, description = "인증된 사용자")
CustomUserDetails user
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public record ChangeRequestResponseDTO(
@JsonRawValue String newValue,
String reason,
Status status,
String adminComment,
AdminUserInfo requestedBy,
LocalDateTime createdAt
) {
Expand All @@ -30,6 +31,7 @@ public static ChangeRequestResponseDTO fromEntity(ChangeRequest changeRequest) {
.newValue(changeRequest.getNewValue())
.reason(changeRequest.getReason())
.status(changeRequest.getStatus())
.adminComment(changeRequest.getAdminComment())
Copy link
Member

Choose a reason for hiding this comment

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

굿!

.requestedBy(AdminUserInfo.fromEntity(changeRequest.getRequestedBy()))
.createdAt(changeRequest.getCreatedAt())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
public interface ChangeRequestRepository extends JpaRepository<ChangeRequest, Long> {
List<ChangeRequest> findAllByStatus(Status status);
List<ChangeRequest> findAllByRequestedBy_UserIdAndStatus(Long userId, Status status);
List<ChangeRequest> findAllByRequestedBy_UserId(Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,10 @@ public List<ChangeRequestResponseDTO> getChangeRequests() {
.map(ChangeRequestResponseDTO::fromEntity)
.collect(Collectors.toList());
}

Copy link
Member

Choose a reason for hiding this comment

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

일단 페이징은 없이가구 제가 시간 되면 공통 페이징 메서드 추가해보겠습니다!

public List<ChangeRequestResponseDTO> getAllChangeRequests() {
return changeRequestRepository.findAll().stream()
Comment on lines +68 to +69
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
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()

Copilot uses AI. Check for mistakes.
.map(ChangeRequestResponseDTO::fromEntity)
.collect(Collectors.toList());
}
Comment on lines +68 to +72
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package DGU_AI_LAB.admin_be.domain.requests.service;

import DGU_AI_LAB.admin_be.domain.portRequests.service.PortRequestService;
import DGU_AI_LAB.admin_be.domain.requests.dto.response.ChangeRequestResponseDTO;
import DGU_AI_LAB.admin_be.domain.requests.dto.response.ContainerInfoDTO;
import DGU_AI_LAB.admin_be.domain.requests.dto.response.PortMappingDTO;
import DGU_AI_LAB.admin_be.domain.requests.dto.response.ResourceUsageDTO;
import DGU_AI_LAB.admin_be.domain.requests.dto.response.SaveRequestResponseDTO;
import DGU_AI_LAB.admin_be.domain.requests.entity.Request;
import DGU_AI_LAB.admin_be.domain.requests.entity.Status;
import DGU_AI_LAB.admin_be.domain.requests.repository.ChangeRequestRepository;
import DGU_AI_LAB.admin_be.domain.requests.repository.RequestRepository;
import DGU_AI_LAB.admin_be.domain.users.repository.UserRepository;
import DGU_AI_LAB.admin_be.error.ErrorCode;
Expand All @@ -25,6 +27,7 @@
public class RequestQueryService {

private final RequestRepository requestRepository;
private final ChangeRequestRepository changeRequestRepository;
private final UserRepository userRepository;
private final PortRequestService portRequestService;

Expand Down Expand Up @@ -79,4 +82,14 @@ public List<SaveRequestResponseDTO> getApprovedRequestsByUserId(Long userId) {
.toList();
}

/** 내 변경 요청 목록 조회 */
public List<ChangeRequestResponseDTO> getMyChangeRequests(Long userId) {
if (!userRepository.existsById(userId)) {
Copy link
Member

Choose a reason for hiding this comment

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

굿!

throw new BusinessException(ErrorCode.USER_NOT_FOUND);
}
return changeRequestRepository.findAllByRequestedBy_UserId(userId).stream()
.map(ChangeRequestResponseDTO::fromEntity)
.toList();
}

}