From 161b7239cc2e7e71518426e0fb3133ec82de0b92 Mon Sep 17 00:00:00 2001 From: Jeong-In-Hee Date: Tue, 14 Nov 2023 23:01:47 +0900 Subject: [PATCH] fix: modify voucher-update-api return value to voucher-update-response-dto --- .../vouchers/controller/VoucherController.java | 3 ++- .../gifthub/vouchers/service/VoucherService.java | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/swmaestro/repl/gifthub/vouchers/controller/VoucherController.java b/src/main/java/org/swmaestro/repl/gifthub/vouchers/controller/VoucherController.java index deac3bea..148e680b 100644 --- a/src/main/java/org/swmaestro/repl/gifthub/vouchers/controller/VoucherController.java +++ b/src/main/java/org/swmaestro/repl/gifthub/vouchers/controller/VoucherController.java @@ -27,6 +27,7 @@ import org.swmaestro.repl.gifthub.vouchers.dto.VoucherShareRequestDto; import org.swmaestro.repl.gifthub.vouchers.dto.VoucherShareResponseDto; import org.swmaestro.repl.gifthub.vouchers.dto.VoucherUpdateRequestDto; +import org.swmaestro.repl.gifthub.vouchers.dto.VoucherUpdateResponseDto; import org.swmaestro.repl.gifthub.vouchers.dto.VoucherUseRequestDto; import org.swmaestro.repl.gifthub.vouchers.dto.VoucherUseResponseDto; import org.swmaestro.repl.gifthub.vouchers.service.PendingVoucherService; @@ -132,7 +133,7 @@ public ResponseEntity listVoucher(HttpServletRequest request, @RequestP }) public ResponseEntity updateVoucher(HttpServletRequest request, @PathVariable Long voucherId, @RequestBody VoucherUpdateRequestDto voucherUpdateRequestDto) throws IOException { - VoucherSaveResponseDto updatedVoucher = voucherService.update(voucherId, voucherUpdateRequestDto); + VoucherUpdateResponseDto updatedVoucher = voucherService.update(voucherId, voucherUpdateRequestDto); return ResponseEntity.ok( SuccessMessage.builder() .path(request.getRequestURI()) diff --git a/src/main/java/org/swmaestro/repl/gifthub/vouchers/service/VoucherService.java b/src/main/java/org/swmaestro/repl/gifthub/vouchers/service/VoucherService.java index f8659a4b..246498ed 100644 --- a/src/main/java/org/swmaestro/repl/gifthub/vouchers/service/VoucherService.java +++ b/src/main/java/org/swmaestro/repl/gifthub/vouchers/service/VoucherService.java @@ -22,6 +22,7 @@ import org.swmaestro.repl.gifthub.vouchers.dto.VoucherShareRequestDto; import org.swmaestro.repl.gifthub.vouchers.dto.VoucherShareResponseDto; import org.swmaestro.repl.gifthub.vouchers.dto.VoucherUpdateRequestDto; +import org.swmaestro.repl.gifthub.vouchers.dto.VoucherUpdateResponseDto; import org.swmaestro.repl.gifthub.vouchers.dto.VoucherUseRequestDto; import org.swmaestro.repl.gifthub.vouchers.dto.VoucherUseResponseDto; import org.swmaestro.repl.gifthub.vouchers.entity.Brand; @@ -163,7 +164,7 @@ public List list(String username) { /* 기프티콘 정보 수정 메서드 */ - public VoucherSaveResponseDto update(Long voucherId, VoucherUpdateRequestDto voucherUpdateRequestDto) { + public VoucherUpdateResponseDto update(Long voucherId, VoucherUpdateRequestDto voucherUpdateRequestDto) { Voucher voucher = voucherRepository.findById(voucherId) .orElseThrow(() -> new BusinessException("존재하지 않는 상품권 입니다.", StatusEnum.NOT_FOUND)); // Balance 수정 @@ -206,8 +207,18 @@ public VoucherSaveResponseDto update(Long voucherId, VoucherUpdateRequestDto vou voucherRepository.save(voucher); - return VoucherSaveResponseDto.builder() + return VoucherUpdateResponseDto.builder() .id(voucherId) + .accessible(voucher.getDeletedAt() == null) + .id(voucher.getId()) + .productId(voucher.getProduct().getId()) + .barcode(voucher.getBarcode()) + .price(voucher.getProduct().getPrice()) + .balance(voucher.getBalance()) + .expiresAt(voucher.getExpiresAt().toString()) + .imageUrl(voucher.getImageUrl()) + .accessible(voucher.getDeletedAt() == null) + .shared(giftCardService.isExist(voucher.getId())) .build(); }