From ba52c5da279404d1a2cd68aa7a5c4c9fe75369f7 Mon Sep 17 00:00:00 2001 From: KarmaPol Date: Thu, 15 Feb 2024 22:16:28 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20item=20=ED=95=98=EB=93=9C=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/mm/coredomain/domain/Item.java | 108 ++++++++++-------- 1 file changed, 59 insertions(+), 49 deletions(-) diff --git a/core/core-domain/src/main/java/com/mm/coredomain/domain/Item.java b/core/core-domain/src/main/java/com/mm/coredomain/domain/Item.java index c76136d..6e761a4 100644 --- a/core/core-domain/src/main/java/com/mm/coredomain/domain/Item.java +++ b/core/core-domain/src/main/java/com/mm/coredomain/domain/Item.java @@ -1,76 +1,86 @@ package com.mm.coredomain.domain; -import jakarta.persistence.*; -import lombok.*; -import org.hibernate.annotations.SQLDelete; - import java.util.ArrayList; import java.util.List; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Lob; +import jakarta.persistence.OneToMany; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + @Entity @Getter @Builder @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor -@SQLDelete(sql = "UPDATE item SET deleted = true WHERE id = ?") public class Item extends BaseEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; - private String title; + private String title; - @Lob - private String redirectUrl; + @Lob + private String redirectUrl; - @Enumerated(value = EnumType.STRING) - private ItemCategoryType categoryType; + @Enumerated(value = EnumType.STRING) + private ItemCategoryType categoryType; - private Integer price; + private Integer price; - private Integer refund; + private Integer refund; - private Double rating; + private Double rating; - @Lob - private String thumbnailUrl; + @Lob + private String thumbnailUrl; - @Builder.Default - private Boolean isSuggested = false; + @Builder.Default + private Boolean isSuggested = false; - @Builder.Default - @OneToMany(mappedBy = "item", cascade = CascadeType.ALL, orphanRemoval = true) - private List itemImages = new ArrayList(); + @Builder.Default + @OneToMany(mappedBy = "item", cascade = CascadeType.ALL, orphanRemoval = true) + private List itemImages = new ArrayList(); - @Builder.Default - @OneToMany(mappedBy = "item", cascade = CascadeType.ALL, orphanRemoval = true) - private List itemVideos = new ArrayList(); + @Builder.Default + @OneToMany(mappedBy = "item", cascade = CascadeType.ALL, orphanRemoval = true) + private List itemVideos = new ArrayList(); - public void setItemImages(List itemImages) { - this.itemImages.clear(); - itemImages.forEach(itemImage -> this.itemImages.add(itemImage)); - } + public void setItemImages(List itemImages) { + this.itemImages.clear(); + itemImages.forEach(itemImage -> this.itemImages.add(itemImage)); + } - public void setItemVideos(List itemVideos) { - this.itemVideos.clear(); - itemVideos.forEach(itemVideo -> this.itemVideos.add(itemVideo)); - } + public void setItemVideos(List itemVideos) { + this.itemVideos.clear(); + itemVideos.forEach(itemVideo -> this.itemVideos.add(itemVideo)); + } - public void setItemSuggested() { - this.isSuggested = true; - } + public void setItemSuggested() { + this.isSuggested = true; + } - public void setItemNotSuggested() { - this.isSuggested = false; - } + public void setItemNotSuggested() { + this.isSuggested = false; + } - public void updateItem(ItemUpdate itemUpdate) { - this.title = itemUpdate.title(); - this.redirectUrl = itemUpdate.redirectUrl(); - this.categoryType = itemUpdate.categoryType(); - this.price = itemUpdate.price(); - this.refund = itemUpdate.refund(); - this.rating = itemUpdate.rating(); - this.thumbnailUrl = itemUpdate.thumbnailUrl(); - } + public void updateItem(ItemUpdate itemUpdate) { + this.title = itemUpdate.title(); + this.redirectUrl = itemUpdate.redirectUrl(); + this.categoryType = itemUpdate.categoryType(); + this.price = itemUpdate.price(); + this.refund = itemUpdate.refund(); + this.rating = itemUpdate.rating(); + this.thumbnailUrl = itemUpdate.thumbnailUrl(); + } }