Skip to content

Commit

Permalink
Merge develop to main (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
inh2613 authored Nov 14, 2023
2 parents 606eb7f + 3bcd9a7 commit 718c1f2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public VoucherReadResponseDto read(Long id, String username) {
// }

VoucherReadResponseDto voucherReadResponseDto = mapToDto(voucher.get());

return voucherReadResponseDto;
}

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 718c1f2

Please sign in to comment.