diff --git a/backend/src/main/java/develup/domain/scrap/Scrap.java b/backend/src/main/java/develup/domain/scrap/Scrap.java new file mode 100644 index 00000000..929e3533 --- /dev/null +++ b/backend/src/main/java/develup/domain/scrap/Scrap.java @@ -0,0 +1,39 @@ +package develup.domain.scrap; + +import develup.domain.IdentifiableEntity; +import develup.domain.member.Member; +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; + +@Entity +public class Scrap extends IdentifiableEntity { + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(nullable = false) + private Member member; + + @Embedded + private ScrappedItem item; + + @Column(nullable = false) + private boolean isScrapped; + + protected Scrap() { + } + + public Scrap(Member member, ScrappedItem item) { + this(null, member, item, true); + } + + public Scrap(Long id, Member member, ScrappedItem item, boolean isScrapped) { + super(id); + this.id = id; + this.member = member; + this.item = item; + this.isScrapped = isScrapped; + } +} diff --git a/backend/src/main/java/develup/domain/scrap/ScrapRepository.java b/backend/src/main/java/develup/domain/scrap/ScrapRepository.java new file mode 100644 index 00000000..e70ce718 --- /dev/null +++ b/backend/src/main/java/develup/domain/scrap/ScrapRepository.java @@ -0,0 +1,6 @@ +package develup.domain.scrap; + +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ScrapRepository extends JpaRepository { +} diff --git a/backend/src/main/java/develup/domain/scrap/ScrappedItem.java b/backend/src/main/java/develup/domain/scrap/ScrappedItem.java new file mode 100644 index 00000000..0438266c --- /dev/null +++ b/backend/src/main/java/develup/domain/scrap/ScrappedItem.java @@ -0,0 +1,25 @@ +package develup.domain.scrap; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; + +@Embeddable +public class ScrappedItem { + + @Column(name = "item_id", nullable = false) + private Long id; + + @Column(nullable = false) + @Enumerated(EnumType.STRING) + private ScrappedItemType itemType; + + protected ScrappedItem() { + } + + public ScrappedItem(Long id, ScrappedItemType itemType) { + this.id = id; + this.itemType = itemType; + } +} diff --git a/backend/src/main/java/develup/domain/scrap/ScrappedItemType.java b/backend/src/main/java/develup/domain/scrap/ScrappedItemType.java new file mode 100644 index 00000000..10518c5e --- /dev/null +++ b/backend/src/main/java/develup/domain/scrap/ScrappedItemType.java @@ -0,0 +1,8 @@ +package develup.domain.scrap; + +public enum ScrappedItemType { + + DISCUSSION, + SOLUTION, + ; +}