Skip to content
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

[Feature] Record와 Memo 엔티티에 필요한 필드 추가 DB에 반영 #53

Merged
merged 3 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/main/java/com/cmc/mercury/domain/memo/entity/Memo.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,20 @@ public class Memo extends BaseEntity {
@JoinColumn(name = "record_detail_id", nullable = false)
private RecordDetail recordDetail;

@Column(nullable = false)
private int acquiredExp;

// 기록 생성 시 추가되는 메모는 경험치 획득하지 않으므로 이를 구분하기 위한 필드
@Column(nullable = false)
private boolean isFirstMemo;

@Builder
public Memo(String content, int gauge, RecordDetail recordDetail) {
public Memo(String content, int gauge, RecordDetail recordDetail, int acquiredExp, boolean isFirstMemo) {
this.content = content;
this.gauge = gauge;
this.recordDetail = recordDetail;
this.acquiredExp = acquiredExp;
this.isFirstMemo = isFirstMemo;
}

// RecordDetail와의 연관관계 메서드
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,19 @@ public class Record extends BaseEntity {
@OneToOne(mappedBy = "record", cascade = CascadeType.ALL, orphanRemoval = true)
private RecordDetail recordDetail;

@Column(nullable = false)
private int acquiredExp;

// 연관관계 메서드
public void setRecordDetail(RecordDetail recordDetail) {
this.recordDetail = recordDetail;
recordDetail.setRecord(this);
}
@Builder
public Record(User user, Book book) {
public Record(User user, Book book, int acquiredExp) {
this.user = user;
this.book = book;
this.acquiredExp = acquiredExp;
}

// 메모 생성, 수정 시 Record와 RecordDetail의 updatedAt을 함께 업데이트
Expand Down