참여자 플로우차트 수정
This commit is contained in:
parent
841d6ef1b7
commit
915446c821
@ -40,6 +40,26 @@ else JWT 검증 성공
|
|||||||
Controller -> Service: drawWinners(eventId, winnerCount, visitBonus)
|
Controller -> Service: drawWinners(eventId, winnerCount, visitBonus)
|
||||||
activate Service
|
activate Service
|
||||||
|
|
||||||
|
Service -> Service: 이벤트 상태 확인\n- 이벤트 종료 여부\n- 이미 추첨 완료 여부
|
||||||
|
|
||||||
|
Service -> LogRepo: findByEventId(eventId)
|
||||||
|
activate LogRepo
|
||||||
|
LogRepo -> DB: SELECT * FROM draw_logs\nWHERE event_id = ?
|
||||||
|
activate DB
|
||||||
|
DB --> LogRepo: 추첨 로그 조회
|
||||||
|
deactivate DB
|
||||||
|
LogRepo --> Service: Optional<DrawLog>
|
||||||
|
deactivate LogRepo
|
||||||
|
|
||||||
|
alt 이미 추첨 완료
|
||||||
|
Service --> Controller: AlreadyDrawnException
|
||||||
|
Controller --> Gateway: 409 Conflict\n{message: "이미 추첨이 완료된 이벤트입니다"}
|
||||||
|
Gateway --> Owner: 409 Conflict
|
||||||
|
deactivate Service
|
||||||
|
deactivate Controller
|
||||||
|
deactivate Gateway
|
||||||
|
else 추첨 가능 상태
|
||||||
|
|
||||||
Service -> Repo: findAllByEventIdAndIsWinner(eventId, false)
|
Service -> Repo: findAllByEventIdAndIsWinner(eventId, false)
|
||||||
activate Repo
|
activate Repo
|
||||||
Repo -> DB: SELECT * FROM participants\nWHERE event_id = ?\nAND is_winner = false\nORDER BY participated_at ASC
|
Repo -> DB: SELECT * FROM participants\nWHERE event_id = ?\nAND is_winner = false\nORDER BY participated_at ASC
|
||||||
@ -58,22 +78,14 @@ else JWT 검증 성공
|
|||||||
deactivate Gateway
|
deactivate Gateway
|
||||||
else 추첨 진행
|
else 추첨 진행
|
||||||
|
|
||||||
Service -> Service: 이벤트 상태 확인\n- 이벤트 종료 여부\n- 이미 추첨 완료 여부
|
|
||||||
|
|
||||||
alt 이벤트가 아직 진행 중
|
|
||||||
Service --> Controller: EventNotEndedException
|
|
||||||
Controller --> Gateway: 400 Bad Request\n{message: "이벤트가 아직 진행 중입니다"}
|
|
||||||
Gateway --> Owner: 400 Bad Request
|
|
||||||
deactivate Service
|
|
||||||
deactivate Controller
|
|
||||||
deactivate Gateway
|
|
||||||
else 추첨 가능 상태
|
|
||||||
|
|
||||||
Service -> Lottery: executeLottery(participants, winnerCount, visitBonus)
|
Service -> Lottery: executeLottery(participants, winnerCount, visitBonus)
|
||||||
activate Lottery
|
activate Lottery
|
||||||
|
|
||||||
note right of Lottery
|
note right of Lottery
|
||||||
추첨 알고리즘:
|
추첨 알고리즘:
|
||||||
|
시간 복잡도: O(n log n)
|
||||||
|
공간 복잡도: O(n)
|
||||||
|
|
||||||
1. 난수 생성 (Crypto.randomBytes)
|
1. 난수 생성 (Crypto.randomBytes)
|
||||||
2. 매장 방문 가산점 적용 (옵션)
|
2. 매장 방문 가산점 적용 (옵션)
|
||||||
- 방문 고객: 가중치 2배
|
- 방문 고객: 가중치 2배
|
||||||
@ -97,6 +109,15 @@ else JWT 검증 성공
|
|||||||
|
|
||||||
Service -> Service: DB 트랜잭션 시작
|
Service -> Service: DB 트랜잭션 시작
|
||||||
|
|
||||||
|
alt DB 저장 실패 시
|
||||||
|
note right of Service
|
||||||
|
트랜잭션 롤백 처리:
|
||||||
|
- 당첨자 업데이트 취소
|
||||||
|
- 추첨 로그 저장 취소
|
||||||
|
- 재시도 가능 상태 유지
|
||||||
|
end note
|
||||||
|
end
|
||||||
|
|
||||||
Service -> Repo: updateWinners(winnerIds)
|
Service -> Repo: updateWinners(winnerIds)
|
||||||
activate Repo
|
activate Repo
|
||||||
Repo -> DB: UPDATE participants\nSET is_winner = true,\nwon_at = NOW()\nWHERE participant_id IN (?)
|
Repo -> DB: UPDATE participants\nSET is_winner = true,\nwon_at = NOW()\nWHERE participant_id IN (?)
|
||||||
|
|||||||
@ -17,7 +17,10 @@ database "Redis Cache<<E>>" as Cache
|
|||||||
Customer -> Gateway: POST /api/v1/participations\n{name, phone, eventId, entryPath, consent}
|
Customer -> Gateway: POST /api/v1/participations\n{name, phone, eventId, entryPath, consent}
|
||||||
activate Gateway
|
activate Gateway
|
||||||
|
|
||||||
Gateway -> Gateway: JWT 토큰 검증\n(선택사항, 비회원 참여 가능)
|
note right of Gateway
|
||||||
|
비회원 참여 가능
|
||||||
|
JWT 검증 불필요
|
||||||
|
end note
|
||||||
|
|
||||||
Gateway -> Controller: POST /participations/register\n{name, phone, eventId, entryPath, consent}
|
Gateway -> Controller: POST /participations/register\n{name, phone, eventId, entryPath, consent}
|
||||||
activate Controller
|
activate Controller
|
||||||
|
|||||||
@ -49,7 +49,7 @@ else JWT 검증 성공
|
|||||||
Service --> Controller: ParticipantListResponse\n(캐시된 데이터)
|
Service --> Controller: ParticipantListResponse\n(캐시된 데이터)
|
||||||
note right of Service
|
note right of Service
|
||||||
캐시된 데이터 반환
|
캐시된 데이터 반환
|
||||||
- TTL: 5분
|
- TTL: 10분
|
||||||
- 실시간 정확도 vs 성능 트레이드오프
|
- 실시간 정확도 vs 성능 트레이드오프
|
||||||
end note
|
end note
|
||||||
Controller --> Gateway: 200 OK\n{participants, totalElements, totalPages}
|
Controller --> Gateway: 200 OK\n{participants, totalElements, totalPages}
|
||||||
@ -73,6 +73,10 @@ else JWT 검증 성공
|
|||||||
- isWinner 필터 (선택)
|
- isWinner 필터 (선택)
|
||||||
- name/phone 검색 (선택)
|
- name/phone 검색 (선택)
|
||||||
- 페이지네이션 (필수)
|
- 페이지네이션 (필수)
|
||||||
|
|
||||||
|
필요 인덱스:
|
||||||
|
idx_participants_event_filters
|
||||||
|
(event_id, entry_path, is_winner, participated_at DESC)
|
||||||
end note
|
end note
|
||||||
|
|
||||||
DB --> Repo: 참여자 목록 결과셋
|
DB --> Repo: 참여자 목록 결과셋
|
||||||
@ -88,12 +92,13 @@ else JWT 검증 성공
|
|||||||
|
|
||||||
Service -> Service: DTO 변환\n- 전화번호 마스킹 (010-****-1234)\n- 응모번호 형식화\n- 당첨 여부 라벨 변환
|
Service -> Service: DTO 변환\n- 전화번호 마스킹 (010-****-1234)\n- 응모번호 형식화\n- 당첨 여부 라벨 변환
|
||||||
|
|
||||||
Service -> Cache: SET participant_list:{key} = data\nTTL: 5분
|
Service -> Cache: SET participant_list:{key} = data\nTTL: 10분
|
||||||
activate Cache
|
activate Cache
|
||||||
note right of Cache
|
note right of Cache
|
||||||
캐시 저장:
|
캐시 저장:
|
||||||
- 짧은 TTL (5분)
|
- TTL: 10분
|
||||||
- 실시간 참여 반영을 위해
|
- 실시간 참여 반영과 성능 균형
|
||||||
|
- 이벤트 참여 빈도 고려
|
||||||
end note
|
end note
|
||||||
Cache --> Service: 캐시 저장 완료
|
Cache --> Service: 캐시 저장 완료
|
||||||
deactivate Cache
|
deactivate Cache
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user