Skip to content

Commit

Permalink
Merge pull request #53 from Central-MakeUs/dev
Browse files Browse the repository at this point in the history
[Feature] Record와 Memo 엔티티에 필요한 필드 추가 DB에 반영
  • Loading branch information
dainnida authored Jan 30, 2025
2 parents 88c246e + 32b90af commit 644230e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
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

0 comments on commit 644230e

Please sign in to comment.