-
Notifications
You must be signed in to change notification settings - Fork 5
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
스크랩 엔티티 구현 (issue #489) #496
base: dev
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ScrapedItem item; | ||
|
||
@Column(nullable = false) | ||
private boolean isScrapped; | ||
Comment on lines
+22
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 해당 컬럼이 존재하는 이유는 사용자가 스크랩 버튼을 반복해서 클릭하는 경우 insert와 delete를 반복해서 수행하는 것보다 update 비용이 더욱 저렴하다고 생각했기 때문입니다.
다른 분들의 의견을 들어보고 싶습니다! 👀 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Comment] 비용이 적을것이라는 것에는 동감합니다. 하지만 그 비용을 아끼는 대가로 나중에 구현될 스크랩 API의 명세가 복잡해지거나 내부 구현이 복잡해질 것 같네요. |
||
|
||
protected Scrap() { | ||
} | ||
|
||
public Scrap(Member member, ScrapedItem item) { | ||
this(null, member, item, true); | ||
} | ||
|
||
public Scrap(Long id, Member member, ScrapedItem item, boolean isScrapped) { | ||
super(id); | ||
this.id = id; | ||
this.member = member; | ||
this.item = item; | ||
this.isScrapped = isScrapped; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package develup.domain.scrap; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface ScrapRepository extends JpaRepository<Scrap, Long> { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ScrapedItem { | ||
|
||
@Column(name = "item_id", nullable = false) | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
@Enumerated(EnumType.STRING) | ||
private ScrapedItemType itemType; | ||
|
||
protected ScrapedItem() { | ||
} | ||
|
||
public ScrapedItem(Long id, ScrapedItemType itemType) { | ||
this.id = id; | ||
this.itemType = itemType; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package develup.domain.scrap; | ||
|
||
public enum ScrapedItemType { | ||
|
||
DISCUSSION, | ||
SOLUTION, | ||
; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Request Changed]
오타 발견! 💡
scrapped
😊There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
변경했습니다. 감사합니다. 👍