From 2a0ebbb801f79c6e7d9b07f953217d888b39745e Mon Sep 17 00:00:00 2001 From: Jinwoo Lee Date: Tue, 24 Oct 2023 13:07:43 +0900 Subject: [PATCH 1/2] feat: implement is-deleted method to voucher --- .../org/swmaestro/repl/gifthub/vouchers/entity/Voucher.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/org/swmaestro/repl/gifthub/vouchers/entity/Voucher.java b/src/main/java/org/swmaestro/repl/gifthub/vouchers/entity/Voucher.java index 22085bae..639cf358 100644 --- a/src/main/java/org/swmaestro/repl/gifthub/vouchers/entity/Voucher.java +++ b/src/main/java/org/swmaestro/repl/gifthub/vouchers/entity/Voucher.java @@ -67,4 +67,8 @@ public Voucher(Long id, Brand brand, Product product, String barcode, Integer ba this.user = user; this.imageUrl = imageUrl; } + + public boolean isDeleted() { + return deletedAt != null; + } } \ No newline at end of file From 03f23febc5c47bc418db2daa711ce47b43594cf0 Mon Sep 17 00:00:00 2001 From: Jinwoo Lee Date: Tue, 24 Oct 2023 13:08:54 +0900 Subject: [PATCH 2/2] fix: modify to prevent access to deleted voucher --- .../repl/gifthub/vouchers/service/VoucherService.java | 3 +++ 1 file changed, 3 insertions(+) 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 54d3d643..5b435d79 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 @@ -108,6 +108,9 @@ public VoucherReadResponseDto read(Long id, String username) { if (!vouchers.contains(voucher.get())) { throw new BusinessException("상품권을 조회할 권한이 없습니다.", StatusEnum.FORBIDDEN); } + if (voucher.get().isDeleted()) { + throw new BusinessException("삭제된 상품권 입니다.", StatusEnum.BAD_REQUEST); + } VoucherReadResponseDto voucherReadResponseDto = mapToDto(voucher.get()); return voucherReadResponseDto;