diff --git a/src/main/java/org/swmaestro/repl/gifthub/vouchers/dto/VoucherReadResponseDto.java b/src/main/java/org/swmaestro/repl/gifthub/vouchers/dto/VoucherReadResponseDto.java index d3f71c1d..c88bd3b8 100644 --- a/src/main/java/org/swmaestro/repl/gifthub/vouchers/dto/VoucherReadResponseDto.java +++ b/src/main/java/org/swmaestro/repl/gifthub/vouchers/dto/VoucherReadResponseDto.java @@ -26,10 +26,12 @@ public class VoucherReadResponseDto { private boolean accessible; @JsonProperty("is_shared") private boolean shared; + @JsonProperty("is_checked") + private boolean checked; @Builder public VoucherReadResponseDto(Long id, Long productId, String barcode, String expiresAt, Integer price, - Integer balance, String imageUrl, boolean accessible, boolean shared) { + Integer balance, String imageUrl, boolean accessible, boolean shared, boolean checked) { this.id = id; this.productId = productId; this.barcode = barcode; @@ -39,5 +41,6 @@ public VoucherReadResponseDto(Long id, Long productId, String barcode, String ex this.imageUrl = imageUrl; this.accessible = accessible; this.shared = shared; + this.checked = checked; } } diff --git a/src/main/java/org/swmaestro/repl/gifthub/vouchers/dto/VoucherUpdateRequestDto.java b/src/main/java/org/swmaestro/repl/gifthub/vouchers/dto/VoucherUpdateRequestDto.java index aa8647a6..466316a8 100644 --- a/src/main/java/org/swmaestro/repl/gifthub/vouchers/dto/VoucherUpdateRequestDto.java +++ b/src/main/java/org/swmaestro/repl/gifthub/vouchers/dto/VoucherUpdateRequestDto.java @@ -19,13 +19,15 @@ public class VoucherUpdateRequestDto { private String productName; private String brandName; private Integer balance; + private Boolean isChecked; @Builder - public VoucherUpdateRequestDto(String barcode, String expiresAt, String productName, String brandName, int balance) { + public VoucherUpdateRequestDto(String barcode, String expiresAt, String productName, String brandName, int balance, boolean isChecked) { this.barcode = barcode; this.expiresAt = expiresAt; this.productName = productName; this.brandName = brandName; this.balance = balance; + this.isChecked = isChecked; } } 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 e8b66623..3b5bb5b2 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 @@ -3,6 +3,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; +import org.hibernate.annotations.ColumnDefault; import org.swmaestro.repl.gifthub.auth.entity.User; import org.swmaestro.repl.gifthub.util.BaseTimeEntity; @@ -55,6 +56,10 @@ public class Voucher extends BaseTimeEntity { @Column private LocalDateTime deletedAt; + @Column(name = "is_checked", columnDefinition = "TINYINT", nullable = false) + @ColumnDefault("0") + private boolean checked; + @Builder public Voucher(Long id, Brand brand, Product product, String barcode, Integer balance, LocalDate expiresAt, String imageUrl, User user) { @@ -71,4 +76,13 @@ public Voucher(Long id, Brand brand, Product product, String barcode, Integer ba public boolean isDeleted() { return deletedAt != null; } + + public boolean isChecked() { + return checked; + } + + public Voucher check() { + this.checked = true; + return this; + } } \ No newline at end of file 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..0902770e 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 @@ -114,6 +114,7 @@ public VoucherReadResponseDto read(Long id, String username) { // } VoucherReadResponseDto voucherReadResponseDto = mapToDto(voucher.get()); + return voucherReadResponseDto; } @@ -204,6 +205,10 @@ public VoucherSaveResponseDto update(Long voucherId, VoucherUpdateRequestDto vou voucher.setBalance(voucherUpdateRequestDto.getBalance() == null ? voucher.getBalance() : voucherUpdateRequestDto.getBalance()); + // isChecked 수정 + voucher.setChecked(voucherUpdateRequestDto.getIsChecked() == null ? voucher.isChecked() : + voucherUpdateRequestDto.getIsChecked()); + voucherRepository.save(voucher); return VoucherSaveResponseDto.builder() @@ -269,6 +274,7 @@ public VoucherReadResponseDto mapToDto(Voucher voucher) { .imageUrl(voucher.getImageUrl()) .accessible(voucher.getDeletedAt() == null) .shared(giftCardService.isExist(voucher.getId())) + .checked(voucher.isChecked()) .build(); return voucherReadResponseDto; }