Skip to content

Commit da525e2

Browse files
Merge pull request #254 from prgrms-web-devcourse-final-project/feat/#244
[Plan] 낙관적 락을 위한 기능 추가 & 리펙터링
2 parents 173e835 + bfc4824 commit da525e2

5 files changed

Lines changed: 424 additions & 267 deletions

File tree

src/main/java/com/back/web7_9_codecrete_be/domain/plans/controller/PlanController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public RsData<ScheduleDeleteResponse> deleteSchedule(
204204
* @return 성공 메시지 (200 OK)
205205
*/
206206
@PatchMapping("/{planId}/participants/{participantId}/role")
207-
@Operation(summary = "참가자 역할 수정", description = "참가자의 역할을 수정합니다. Owner(소유자), Editor(편집자), Viewer(조회자) 중 하나로 설정할 수 있습니다. 계획의 소유자만 다른 참가자의 역할을 수정할 수 있습니다.")
207+
@Operation(summary = "참가자 역할 수정", description = "참가자의 역할을 수정합니다. Owner(소유자), Editor(편집자), Viewer(조회자) 중 하나로 설정할 수 있습니다. 계획의 소유자 또는 편집 권한이 있는 사용자만 다른 참가자의 역할을 수정할 수 있습니다.")
208208
public RsData<Void> updateParticipantRole(
209209
@PathVariable Long planId,
210210
@PathVariable Long participantId,

src/main/java/com/back/web7_9_codecrete_be/domain/plans/entity/Plan.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ public class Plan {
5151
@Column(name = "modified_date", nullable = false)
5252
private LocalDateTime modifiedDate;
5353

54+
// 낙관적 잠금을 위한 버전 필드
55+
@Version
56+
@Column(name = "version", nullable = false)
57+
private Long version;
58+
5459
@Column(name = "share_token", unique = true, length = 13)
5560
private String shareToken;
5661

@@ -92,10 +97,13 @@ public void addSchedule(Schedule schedule) {
9297
schedule.setPlan(this);
9398
}
9499

100+
private static final int SHARE_TOKEN_LENGTH = 13;
101+
private static final int SHARE_TOKEN_EXPIRY_DAYS = 1;
102+
95103
public void generateShareToken() {
96-
this.shareToken = UUID.randomUUID().toString().substring(0, 13);
104+
this.shareToken = UUID.randomUUID().toString().substring(0, SHARE_TOKEN_LENGTH);
97105
// 만료 시간: 현재 시간으로부터 1일 후
98-
this.shareTokenExpiresAt = LocalDateTime.now().plusDays(1);
106+
this.shareTokenExpiresAt = LocalDateTime.now().plusDays(SHARE_TOKEN_EXPIRY_DAYS);
99107
}
100108

101109
public void clearShareToken() {

src/main/java/com/back/web7_9_codecrete_be/domain/plans/entity/Schedule.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ public class Schedule {
8686
@Column(name = "is_main_event", nullable = false)
8787
private Boolean isMainEvent = false;
8888

89+
// 낙관적 잠금을 위한 버전 필드
90+
@Version
91+
@Column(name = "version", nullable = false)
92+
private Long version;
93+
8994

9095
@Builder
9196
public Schedule(Plan plan, ScheduleType scheduleType, String title,

0 commit comments

Comments
 (0)