Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify to prevent access to deleted voucher #138

Merged
merged 2 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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