Skip to content

Commit

Permalink
fix: modify voucher-update-api return value to voucher-update-respons…
Browse files Browse the repository at this point in the history
…e-dto
  • Loading branch information
inh2613 committed Nov 14, 2023
1 parent 5567eac commit 161b723
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -132,7 +133,7 @@ public ResponseEntity<Message> listVoucher(HttpServletRequest request, @RequestP
})
public ResponseEntity<Message> 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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -163,7 +164,7 @@ public List<Long> 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 수정
Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit 161b723

Please sign in to comment.