Skip to content

Commit e4dd29d

Browse files
[EA3-134] refactor : version 필드 추가 및 of 생성 메서드, addVotes 유틸 메서드 추가
1 parent 52c2a88 commit e4dd29d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/main/java/grep/neogulcoder/domain/timevote/entity/TimeVoteStat.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import jakarta.persistence.Id;
1010
import jakarta.persistence.JoinColumn;
1111
import jakarta.persistence.ManyToOne;
12+
import jakarta.persistence.Version;
1213
import java.time.LocalDateTime;
1314
import lombok.Builder;
1415
import lombok.Getter;
@@ -31,6 +32,9 @@ public class TimeVoteStat extends BaseEntity {
3132
@Column(nullable = false)
3233
private Long voteCount;
3334

35+
@Version
36+
private Long version;
37+
3438
protected TimeVoteStat() {};
3539

3640
@Builder
@@ -39,4 +43,16 @@ public TimeVoteStat(TimeVotePeriod period, LocalDateTime timeSlot, Long voteCoun
3943
this.timeSlot = timeSlot;
4044
this.voteCount = voteCount;
4145
}
46+
47+
public static TimeVoteStat of(TimeVotePeriod period, LocalDateTime timeSlot, Long voteCount) {
48+
return TimeVoteStat.builder()
49+
.period(period)
50+
.timeSlot(timeSlot)
51+
.voteCount(voteCount)
52+
.build();
53+
}
54+
55+
public void addVotes(Long countToAdd) {
56+
this.voteCount += countToAdd;
57+
}
4258
}

0 commit comments

Comments
 (0)