-
Notifications
You must be signed in to change notification settings - Fork 0
refactor(reservation): 예약 상태 변경 #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The head ref may contain hidden characters: "feature/#55-\uC608\uC57D_\uAE30\uBCF8CRUD"
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.example.gtable.reservation.dto; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| import com.example.gtable.reservation.entity.Reservation; | ||
|
|
||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| public class CallGetResponseDto { | ||
| private Long id; | ||
| private Long storeId; | ||
| private String userName; | ||
| private LocalDateTime requestedAt; | ||
| private String status; | ||
| private Integer partySize; | ||
|
|
||
| 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(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package com.example.gtable.reservation.dto; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| @AllArgsConstructor | ||
| public class ReservationStatusSummaryDto { | ||
| private int waitingCount; | ||
| private int confirmedCount; | ||
| private int cancelledCount; | ||
| private int callingCount; | ||
| private List<ReservationGetResponseDto> reservationList; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.example.gtable.reservation.dto; | ||
|
|
||
| import com.example.gtable.reservation.entity.ReservationStatus; | ||
|
|
||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| public class ReservationStatusUpdateRequestDto { | ||
| private ReservationStatus status; | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -36,4 +36,8 @@ public class Reservation { | |||||||||||||||||||
| @Column(name = "party_size", nullable = false) | ||||||||||||||||||||
| private Integer partySize; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| public void updateStatus(ReservationStatus status) { | ||||||||||||||||||||
| this.status = status; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
+39
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
|
|
||||||||||||||||||||
| } | ||||||||||||||||||||
There was a problem hiding this comment.
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
🤖 Prompt for AI Agents