Skip to content

Commit

Permalink
feat: 사용자의 남은 순번 조회 api 구현
Browse files Browse the repository at this point in the history
`WaitingManager`에 남은 순번 조회를 위한 추상 메서드를 정의함.
  • Loading branch information
hseong3243 committed Aug 16, 2024
1 parent 00868e1 commit 5dc4016
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.thirdparty.ticketing.domain.waiting;

import java.util.Map;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.thirdparty.ticketing.domain.common.LoginMember;
import com.thirdparty.ticketing.domain.waiting.manager.WaitingManager;

import lombok.RequiredArgsConstructor;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api")
public class WaitingController {

private final WaitingManager waitingManager;

@GetMapping("/performances/{performanceId}/wait")
public ResponseEntity<Map<String, Long>> getCounts(
@LoginMember String email, @PathVariable("performanceId") Long performanceId) {
long remainingCount = waitingManager.getRemainingCount(email, performanceId);
return ResponseEntity.ok(Map.of("remainingCount", remainingCount));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ protected long countManagedMember(WaitingMember waitingMember) {
return map.get(performanceId);
}

@Override
public long getRemainingCount(String email, Long performanceId) {
return 0;
}

public void moveWaitingMemberToRunningRoom(long performanceId, long count) {
List<WaitingMember> waitingMembers = waitingRoom.pollWaitingMembers(performanceId, count);
long maxCount = 0L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,13 @@ public long enterWaitingRoom(WaitingMember waitingMember) {
}

protected abstract long countManagedMember(WaitingMember waitingMember);

/**
* 사용자의 남은 순번을 조회한다. 남은 순번이 1이하인 경우 이벤트를 발행한다.
*
* @param email 사용자의 이메일
* @param performanceId 공연 대기 정보 조회를 위한 공연 ID
* @return 사용자의 남은 순번
*/
public abstract long getRemainingCount(String email, Long performanceId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ protected long countManagedMember(WaitingMember waitingMember) {
return Long.parseLong(managedMemberCounter.get(key));
}

@Override
public long getRemainingCount(String email, Long performanceId) {
return 0;
}

private String getPerformanceManagedMemberCounterKey(WaitingMember waitingMember) {
return MANAGED_MEMBER_COUNTER_KEY + waitingMember.getPerformanceId();
}
Expand Down

0 comments on commit 5dc4016

Please sign in to comment.