Skip to content

Commit

Permalink
fix: reservation date 중복 처리 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
daeun084 committed Feb 19, 2024
1 parent 192d79b commit cdac255
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import umc.meme.shop.global.exception.GlobalException;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -75,7 +76,7 @@ public ReservationCompleteDto createReservation(ReservationRequestDto reservatio
for(int i=0; i<reservationList.size(); i++){
Reservation reservation = reservationList.get(i);
if(reservation.getReservationDayOfWeekAndTime().equals(reservationDto.getReservationDayOfWeekAndTime())
&& reservation.getReservationDate().equals(reservationDto.getReservationDate())){
&& checkDuplicateReservation(reservation.getReservationDate(), reservationDto.getReservationDate())){
throw new GlobalException(ErrorStatus.NOT_ALLOW_DUPLICATED_RESERVATION);
}
}
Expand Down Expand Up @@ -126,5 +127,15 @@ public List<ReservationResponseDto> getModelReservation(Long modelId) {
.collect(Collectors.toList());
}

private boolean checkDuplicateReservation(Date date1, Date date2){
//두 date가 동일하면 false
if(date1.getYear() == date2.getYear()){
if(date1.getMonth() == date2.getMonth())
if(date1.getDay() == date2.getDay())
return true;
}
return false;
}


}

0 comments on commit cdac255

Please sign in to comment.