-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/main/java/com/dnd/jjakkak/domain/schedule/facade/ScheduleFacade.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.dnd.jjakkak.domain.schedule.facade; | ||
|
||
import com.dnd.jjakkak.domain.redis.RedisRepository; | ||
import com.dnd.jjakkak.domain.schedule.dto.request.ScheduleAssignRequestDto; | ||
import com.dnd.jjakkak.domain.schedule.dto.response.ScheduleAssignResponseDto; | ||
import com.dnd.jjakkak.domain.schedule.service.ScheduleService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* 일정 Facade 클래스입니다. | ||
* | ||
* @author 정승조 | ||
* @version 2024. 10. 11. | ||
*/ | ||
@Slf4j | ||
@Component | ||
@RequiredArgsConstructor | ||
public class ScheduleFacade { | ||
|
||
private final RedisRepository redisRepository; | ||
private final ScheduleService scheduleService; | ||
|
||
public void assignScheduleToMember(Long memberId, String meetingUuid, ScheduleAssignRequestDto requestDto) { | ||
String key = "meeting-" + meetingUuid; | ||
while (!redisRepository.lock(key)) { | ||
try { | ||
Thread.sleep(100); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
try { | ||
scheduleService.assignScheduleToMember(memberId, meetingUuid, requestDto); | ||
} finally { | ||
redisRepository.delete(key); | ||
} | ||
} | ||
|
||
public ScheduleAssignResponseDto assignScheduleToGuest(String meetingUuid, ScheduleAssignRequestDto requestDto) { | ||
String key = "meeting-" + meetingUuid; | ||
while (!redisRepository.lock(key)) { | ||
try { | ||
Thread.sleep(100); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
try { | ||
return scheduleService.assignScheduleToGuest(meetingUuid, requestDto); | ||
} finally { | ||
redisRepository.delete(key); | ||
} | ||
} | ||
} |