Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: 사용자는 남은 대기 순번을 확인할 수 있다. #61

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading