Skip to content

Commit

Permalink
Modify to prevent access to deleted voucher (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinlee1703 authored Oct 24, 2023
2 parents 405b00f + 03f23fe commit cad85e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit cad85e8

Please sign in to comment.