Skip to content

Conversation

@HyemIin
Copy link
Member

@HyemIin HyemIin commented Jun 24, 2025

작업 요약

  • 상태 변경(update) 코드 추가
  • 상태별 예약팀 수 카운트 칼럼 추가

Issue Link

문제점 및 어려움

해결 방안

Reference

Summary by CodeRabbit

  • 신규 기능

    • 매장별 예약 목록 조회 시 대기, 확정, 취소, 호출 상태별 예약 건수와 예약 리스트를 함께 제공하는 요약 정보를 추가했습니다.
    • 예약 상태를 변경할 수 있는 관리자용 PATCH 엔드포인트가 추가되었습니다.
  • 버그 수정

    • 예약 목록이 요청 시간 기준 오름차순으로 정렬되어 조회됩니다.
  • 기타

    • 예약 상태 변경 요청 및 응답에 사용할 새로운 데이터 형식이 도입되었습니다.

- 상태 변경(update) 코드 추가
- 상태별 예약팀 수 카운트 칼럼 추가
@HyemIin HyemIin self-assigned this Jun 24, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jun 24, 2025

Walkthrough

예약 관리 기능이 전반적으로 개선되었습니다. 예약 목록 조회 시 상태별 요약 정보와 함께 상세 목록이 반환되도록 변경되었으며, 예약 상태를 업데이트하는 새로운 PATCH 엔드포인트와 관련 DTO, 서비스 로직이 추가되었습니다. 또한, 예약 목록 조회 시 요청 시간 기준 오름차순 정렬이 적용되었습니다.

Changes

파일/경로 요약 변경 내용 요약
.../controller/ReservationController.java 예약 목록 반환 타입을 요약 DTO로 변경, 예약 상태 변경 PATCH 엔드포인트 추가, 불필요 주석 제거
.../dto/CallGetResponseDto.java
.../dto/ReservationStatusSummaryDto.java
.../dto/ReservationStatusUpdateRequestDto.java
예약 상태 변경 및 요약 관련 신규 DTO 3종 추가
.../entity/Reservation.java 예약 상태를 변경하는 updateStatus 메서드 추가
.../repository/ReservationRepository.java 예약 목록 조회 메서드에 요청 시간 오름차순 정렬 조건 추가
.../service/ReservationService.java 예약 목록 반환 타입을 요약 DTO로 변경, 예약 상태 변경 서비스 메서드 추가

Sequence Diagram(s)

sequenceDiagram
    participant Admin as 관리자(관리자)
    participant Controller as ReservationController
    participant Service as ReservationService
    participant Repository as ReservationRepository
    participant Entity as Reservation

    Admin->>Controller: PATCH /admin/updates/{reservationId} (status 변경 요청)
    Controller->>Service: updateReservationStatus(reservationId, requestDto)
    Service->>Repository: findById(reservationId)
    Repository-->>Service: Reservation 엔티티 반환
    Service->>Entity: updateStatus(status)
    Service->>Repository: 저장(변경된 Reservation)
    Service-->>Controller: CallGetResponseDto 반환
    Controller-->>Admin: ApiResponse.success(CallGetResponseDto)
Loading
sequenceDiagram
    participant User as 사용자(점주)
    participant Controller as ReservationController
    participant Service as ReservationService
    participant Repository as ReservationRepository

    User->>Controller: GET /stores/{storeId}/reservations
    Controller->>Service: getReservationListByStoreId(storeId)
    Service->>Repository: findAllByStore_StoreIdOrderByRequestedAtAsc(storeId)
    Repository-->>Service: Reservation 목록 반환
    Service-->>Controller: ReservationStatusSummaryDto 반환
    Controller-->>User: ReservationStatusSummaryDto 반환
Loading

Poem

예약의 흐름이 새로워졌네
상태별 요약, 한눈에 쏙!
PATCH로 바뀌는 예약의 운명
요청 시간 따라 정렬된 목록
새로운 DTO 친구들도 안녕!
꼼꼼하게 바뀐 코드에
오늘도 평화가 깃들기를 🌱

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (4)
src/main/java/com/example/gtable/reservation/dto/ReservationStatusUpdateRequestDto.java (1)

10-12: 요청 DTO에 유효성 검증 어노테이션을 추가하는 것을 고려해보세요.

DTO 구조가 깔끔하게 설계되었습니다. 다만 API의 안정성을 높이기 위해 필수 필드에 대한 검증을 추가하면 더욱 좋을 것 같습니다.

+import jakarta.validation.constraints.NotNull;
+
 @Getter
 @Builder
 public class ReservationStatusUpdateRequestDto {
+    @NotNull(message = "예약 상태는 필수입니다")
     private ReservationStatus status;
 }
src/main/java/com/example/gtable/reservation/controller/ReservationController.java (1)

66-79: 새로운 PATCH 엔드포인트 구현이 잘 되었습니다.

예약 상태 업데이트를 위한 RESTful한 API 설계가 적절합니다. Swagger 문서화도 잘 되어 있어 API 사용성이 좋을 것 같습니다.

다만 한 가지 개선 제안이 있습니다:

매개변수 형식을 더 읽기 쉽게 개선할 수 있습니다:

-	public ResponseEntity<?> updateReservationStatus(@PathVariable Long reservationId,@RequestBody
-		ReservationStatusUpdateRequestDto requestDto) {
+	public ResponseEntity<?> updateReservationStatus(@PathVariable Long reservationId, 
+		@RequestBody ReservationStatusUpdateRequestDto requestDto) {
src/main/java/com/example/gtable/reservation/service/ReservationService.java (2)

63-63: 상태별 카운팅 로직이 잘 구현되었지만 성능 개선 여지가 있습니다.

현재 구현은 기능적으로 올바르지만, 상태별 카운팅과 DTO 변환을 위해 리스트를 두 번 순회하고 있습니다.

단일 루프로 최적화하여 성능을 개선할 수 있습니다:

		// 상태별 카운트 집계
		int waitingCount = 0;
		int confirmedCount = 0;
		int cancelledCount = 0;
		int callingCount = 0;
		List<ReservationGetResponseDto> reservationDtoList = new ArrayList<>();
		for (Reservation r : reservations) {
-			if (r.getStatus() == ReservationStatus.WAITING) waitingCount++;
-			if (r.getStatus() == ReservationStatus.CONFIRMED) confirmedCount++;
-			if (r.getStatus() == ReservationStatus.CANCELLED) cancelledCount++;
-			if (r.getStatus() == ReservationStatus.CALLING) callingCount++;
+			// 상태별 카운트 증가
+			switch (r.getStatus()) {
+				case WAITING -> waitingCount++;
+				case CONFIRMED -> confirmedCount++;
+				case CANCELLED -> cancelledCount++;
+				case CALLING -> callingCount++;
+			}
			reservationDtoList.add(ReservationGetResponseDto.fromEntity(r));
		}

이렇게 하면 각 예약에 대해 4번의 if 검사 대신 1번의 switch 문으로 처리할 수 있어 더 효율적입니다.

Also applies to: 65-86


87-94: 예약 상태 업데이트 메서드가 깔끔하게 구현되었습니다.

트랜잭션 처리와 예외 처리가 적절히 되어 있고, 엔티티의 updateStatus 메서드를 활용한 것도 좋은 설계입니다.

다만 검증 로직 추가를 고려해보시면 좋을 것 같습니다:

상태 전환 규칙 검증을 추가하면 더 안전한 코드가 될 수 있습니다:

	@Transactional
	public CallGetResponseDto updateReservationStatus(Long reservationId, ReservationStatusUpdateRequestDto requestDto) {
		Reservation reservation = reservationRepository.findById(reservationId)
			.orElseThrow(() -> new IllegalArgumentException("존재하지 않는 reservation"));
+		
+		// 상태 전환 유효성 검증 (예시)
+		validateStatusTransition(reservation.getStatus(), requestDto.getStatus());
+		
		reservation.updateStatus(requestDto.getStatus());
		return CallGetResponseDto.fromEntity(reservation);
	}

예를 들어, 취소된 예약을 다시 대기 상태로 변경하는 것을 방지하는 등의 비즈니스 규칙을 추가할 수 있습니다.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1cf53ef and 9fe7478.

📒 Files selected for processing (7)
  • src/main/java/com/example/gtable/reservation/controller/ReservationController.java (3 hunks)
  • src/main/java/com/example/gtable/reservation/dto/CallGetResponseDto.java (1 hunks)
  • src/main/java/com/example/gtable/reservation/dto/ReservationStatusSummaryDto.java (1 hunks)
  • src/main/java/com/example/gtable/reservation/dto/ReservationStatusUpdateRequestDto.java (1 hunks)
  • src/main/java/com/example/gtable/reservation/entity/Reservation.java (1 hunks)
  • src/main/java/com/example/gtable/reservation/repository/ReservationRepository.java (1 hunks)
  • src/main/java/com/example/gtable/reservation/service/ReservationService.java (2 hunks)
🔇 Additional comments (5)
src/main/java/com/example/gtable/reservation/repository/ReservationRepository.java (1)

10-10: 정렬 기능이 추가된 메서드명 변경이 적절합니다.

요청 시간 기준 오름차순 정렬을 메서드명에 명시적으로 표현하여 코드의 가독성과 예측가능성이 향상되었습니다. 이는 예약 목록을 일관된 순서로 제공하는 데 도움이 될 것입니다.

src/main/java/com/example/gtable/reservation/dto/ReservationStatusSummaryDto.java (1)

12-18: 상태 요약 DTO의 구조가 잘 설계되었습니다.

상태별 개수와 상세 목록을 하나의 응답으로 제공하는 구조가 매우 실용적입니다. 필드명도 직관적이고 명확하여 API 사용자가 쉽게 이해할 수 있을 것입니다.

src/main/java/com/example/gtable/reservation/controller/ReservationController.java (2)

6-12: 임포트 구문 정리가 잘 되었습니다!

와일드카드 임포트에서 구체적인 임포트로 변경하신 것이 좋은 개선사항입니다. 코드의 명확성과 IDE 성능 향상에 도움이 됩니다.

Also applies to: 16-16, 19-20, 23-26


56-56: 반환 타입 변경이 적절합니다.

ReservationStatusSummaryDto로 변경하여 상태별 카운트 정보와 함께 예약 목록을 제공하는 것이 사용자 경험 개선에 도움이 될 것 같습니다.

src/main/java/com/example/gtable/reservation/service/ReservationService.java (1)

4-4: 필요한 임포트들이 적절히 추가되었습니다.

새로운 기능 구현을 위한 임포트들이 깔끔하게 정리되어 있습니다.

Also applies to: 11-11, 15-16

Comment on lines +39 to +41
public void updateStatus(ReservationStatus status) {
this.status = status;
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

상태 업데이트 메서드에 입력값 검증을 추가해주세요.

메서드가 깔끔하게 구현되었지만, null 값에 대한 검증이 없어서 안전성을 높이기 위해 개선이 필요합니다.

 public void updateStatus(ReservationStatus status) {
+    if (status == null) {
+        throw new IllegalArgumentException("예약 상태는 null일 수 없습니다.");
+    }
     this.status = status;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public void updateStatus(ReservationStatus status) {
this.status = status;
}
public void updateStatus(ReservationStatus status) {
if (status == null) {
throw new IllegalArgumentException("예약 상태는 null일 수 없습니다.");
}
this.status = status;
}
🤖 Prompt for AI Agents
In src/main/java/com/example/gtable/reservation/entity/Reservation.java around
lines 39 to 41, the updateStatus method lacks validation for null input, which
can lead to unsafe state changes. Add a null check at the start of the method to
verify that the status parameter is not null, and handle the null case
appropriately, such as throwing an IllegalArgumentException or ignoring the
update, to ensure method robustness.

Comment on lines +20 to +29
public static CallGetResponseDto fromEntity(Reservation reservation) {
return CallGetResponseDto.builder()
.id(reservation.getId())
.storeId(reservation.getStore().getStoreId())
.userName(reservation.getUser().getNickname())
.requestedAt(reservation.getRequestedAt())
.status(reservation.getStatus().name())
.partySize(reservation.getPartySize())
.build();
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

fromEntity 메서드에 null 안전성 검증을 추가해주세요.

DTO 변환 로직이 깔끔하게 구현되었습니다. 다만 연관 엔티티들이 null일 가능성에 대비한 안전장치를 추가하면 더욱 안정적인 코드가 될 것입니다.

 public static CallGetResponseDto fromEntity(Reservation reservation) {
+    if (reservation == null) {
+        throw new IllegalArgumentException("예약 정보는 null일 수 없습니다.");
+    }
+    if (reservation.getStore() == null || reservation.getUser() == null) {
+        throw new IllegalStateException("예약의 매장 또는 사용자 정보가 누락되었습니다.");
+    }
+    
     return CallGetResponseDto.builder()
         .id(reservation.getId())
         .storeId(reservation.getStore().getStoreId())
         .userName(reservation.getUser().getNickname())
         .requestedAt(reservation.getRequestedAt())
         .status(reservation.getStatus().name())
         .partySize(reservation.getPartySize())
         .build();
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public static CallGetResponseDto fromEntity(Reservation reservation) {
return CallGetResponseDto.builder()
.id(reservation.getId())
.storeId(reservation.getStore().getStoreId())
.userName(reservation.getUser().getNickname())
.requestedAt(reservation.getRequestedAt())
.status(reservation.getStatus().name())
.partySize(reservation.getPartySize())
.build();
}
public static CallGetResponseDto fromEntity(Reservation reservation) {
if (reservation == null) {
throw new IllegalArgumentException("예약 정보는 null일 수 없습니다.");
}
if (reservation.getStore() == null || reservation.getUser() == null) {
throw new IllegalStateException("예약의 매장 또는 사용자 정보가 누락되었습니다.");
}
return CallGetResponseDto.builder()
.id(reservation.getId())
.storeId(reservation.getStore().getStoreId())
.userName(reservation.getUser().getNickname())
.requestedAt(reservation.getRequestedAt())
.status(reservation.getStatus().name())
.partySize(reservation.getPartySize())
.build();
}
🤖 Prompt for AI Agents
In src/main/java/com/example/gtable/reservation/dto/CallGetResponseDto.java
around lines 20 to 29, the fromEntity method lacks null safety checks for
associated entities like store and user. To fix this, add null checks before
accessing properties of reservation.getStore() and reservation.getUser() to
avoid NullPointerExceptions. Use conditional checks or Optional to safely
retrieve values or provide default values when these related entities are null.

@HyemIin HyemIin merged commit 1f02ce2 into develop Jun 24, 2025
1 of 2 checks passed
@HyemIin HyemIin deleted the feature/#55-예약_기본CRUD branch June 24, 2025 08:26
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.

2 participants