Skip to content
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

hotfix: #71 Delete 메소드 RequestBody -> PathVariable #103

Merged
merged 1 commit into from
Jun 7, 2024
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 @@ -122,10 +122,10 @@ public ResponseEntity<Response<Void>> reserveMeetingRoom(@AuthenticationPrincipa
@Parameters({
@Parameter(name = "access", hidden = true)
})
@DeleteMapping("/meeting-rooms")
@DeleteMapping("/meeting-rooms/{reservationId}")
public ResponseEntity<Response<Void>> cancelMeetingRoomReservation(@AuthenticationPrincipal AuthRequestDto.Access access,
@Valid @RequestBody ReservationRequestDto.MeetingRoomReservationCancel cancelDto) {
reservationService.cancelMeetingRoom(access.getEmail(), cancelDto);
@RequestBody Long reservationId) {
reservationService.cancelMeetingRoom(access.getEmail(), reservationId);
return ResponseEntity.ok(Response.success(null));
}

Expand Down Expand Up @@ -163,10 +163,10 @@ public ResponseEntity<Response<ReservationResponseDto.CheckOverlap>> checkOverla
@Parameters({
@Parameter(name = "access", hidden = true)
})
@DeleteMapping("/focus-desks")
@DeleteMapping("/focus-desks/{focusDeskId}")
public ResponseEntity<Response<Void>> endUseDesk(@AuthenticationPrincipal AuthRequestDto.Access access,
@Valid @RequestBody ReservationRequestDto.FocusDeskDto focusDeskDto) {
reservationService.endUseFocusDesk(access.getEmail(), focusDeskDto);
@RequestBody Long focusDeskId) {
reservationService.endUseFocusDesk(access.getEmail(), focusDeskId);
return ResponseEntity.ok(Response.success(null));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ public Reservation toReservationEntity(MeetingRoom meetingRoom, Member represent
}
}

public record MeetingRoomReservationCancel(
@Positive
Long reservationId) {
}

public record FocusDeskDto(
@Positive
Long focusDeskId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.example.sabujak.member.entity.Member;
import com.example.sabujak.member.repository.MemberRepository;
import com.example.sabujak.reservation.dto.ReserveMeetingRoomEvent;
import com.example.sabujak.reservation.dto.FindMeetingRoomEntryNotificationMembersEvent;
import com.example.sabujak.reservation.dto.ReserveMeetingRoomEvent;
import com.example.sabujak.reservation.dto.request.ReservationRequestDto;
import com.example.sabujak.reservation.dto.response.ReservationHistoryResponse;
import com.example.sabujak.reservation.dto.response.ReservationProgress;
Expand All @@ -22,7 +22,6 @@
import com.example.sabujak.space.repository.meetingroom.MeetingRoomRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.annotations.processing.Find;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -175,14 +174,14 @@ public void reserveFocusDesk(String email, ReservationRequestDto.FocusDeskDto fo
}

@Transactional
public void endUseFocusDesk(String email, ReservationRequestDto.FocusDeskDto focusDeskDto) {
public void endUseFocusDesk(String email, Long spaceId) {

LocalDateTime now = LocalDateTime.now();

final Member member = memberRepository.findByMemberEmail(email)
.orElseThrow(() -> new AuthException(ACCOUNT_NOT_EXISTS));

FocusDesk focusDesk = focusDeskRepository.findById(focusDeskDto.focusDeskId())
FocusDesk focusDesk = focusDeskRepository.findById(spaceId)
.orElseThrow(() -> new SpaceException(FOCUS_DESK_NOT_FOUND));

// 해당 회원이 당일 예약한 포커스 데스크를 시간순으로 가져옴
Expand Down Expand Up @@ -378,13 +377,13 @@ public ReservationHistoryResponse.ReservationDetails getReservationDetails(Strin
}

@Transactional
public void cancelMeetingRoom(String email, ReservationRequestDto.MeetingRoomReservationCancel cancelDto) {
public void cancelMeetingRoom(String email, Long reservationId) {
LocalDateTime now = LocalDateTime.now();

final Member member = memberRepository.findByMemberEmail(email)
.orElseThrow(() -> new AuthException(ACCOUNT_NOT_EXISTS));

Reservation reservation = reservationRepository.findById(cancelDto.reservationId())
Reservation reservation = reservationRepository.findById(reservationId)
.orElseThrow(() -> new ReservationException(RESERVATION_NOT_EXISTS));

if (reservation.getReservationEndDateTime().isBefore(now)) {
Expand Down
Loading