Skip to content

Commit

Permalink
fix: Save Dto 로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
min9805 committed May 30, 2024
1 parent 531783f commit 4c08856
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public class ReservationController {
value = "{ \"status\" : \"CONFLICT\", \"message\" : \"존재하지 않는 외래키입니다. : 테이블\"}")
)
)
public ResponseEntity<String> saveReservation(@CurrentUser User user,
@RequestBody @Valid SaveReservationRequest orderDto) {
public ResponseEntity<MerchantDto> saveReservation(@CurrentUser User user,
@RequestBody @Valid SaveReservationRequest orderDto) {
log.info("Received orders: {}", orderDto.toString());
return ResponseEntity.ok(reservationService.saveReservation(user.getId(), orderDto));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class ReservationService {
* @param reservation
* @return
*/
public String saveReservation(Long clientId, SaveReservationRequest reservation) {
public MerchantDto saveReservation(Long clientId, SaveReservationRequest reservation) {
try {
GuideProduct guideProduct = guideProductRepository.findById(reservation.getProductId()).orElseThrow(
() -> new GuideProductNotFoundException(reservation.getProductId())
Expand All @@ -56,13 +56,15 @@ public String saveReservation(Long clientId, SaveReservationRequest reservation)
}

Reservation save = reservationRepository.save(entity);
return save.getMerchantUid();

return MerchantDto.builder().
merchantUid(save.getMerchantUid()).build();
} catch (DataIntegrityViolationException e) {
log.info(e.getMessage());
throw new ForeignKeyConstraintViolationException("GuideProduct or User");
} catch (Exception e) {
log.info(e.getMessage());
return "예약 정보 저장에 실패했습니다.";
return null;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.swygbro.trip.backend.domain.reservation.dto;

import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public class MerchantDto {
String merchantUid;
}

0 comments on commit 4c08856

Please sign in to comment.