|
1 | 1 | package com.waitit.capstone.domain.queue.controller; |
2 | 2 |
|
| 3 | +import com.waitit.capstone.domain.manager.dto.HostResponse; |
| 4 | +import com.waitit.capstone.domain.manager.service.HostService; |
3 | 5 | import com.waitit.capstone.domain.queue.QueueMapper; |
4 | 6 | import com.waitit.capstone.domain.queue.dto.QueResponseDto; |
5 | 7 | import com.waitit.capstone.domain.queue.dto.QueueDto; |
| 8 | +import com.waitit.capstone.domain.queue.dto.QueueRegistrationResponse; |
6 | 9 | import com.waitit.capstone.domain.queue.dto.QueueRequest; |
7 | 10 |
|
8 | 11 | import com.waitit.capstone.domain.queue.service.QueueService; |
|
21 | 24 | public class QueueController { |
22 | 25 | private final QueueService queueService; |
23 | 26 | private final QueueMapper queueMapper; |
| 27 | + private final HostService hostService; // HostService 주입 추가 |
24 | 28 |
|
25 | | - // 롱폴링 관련 코드 모두 삭제 |
26 | | - |
27 | | - @Operation(summary = "대기열 등록", description = "특정 가게의 대기열에 사용자를 등록합니다.") |
| 29 | + @Operation(summary = "대기열 등록", description = "특정 가게의 대기열에 사용자를 등록하고, 등록된 가게의 상세 정보를 함께 반환합니다.") |
28 | 30 | @PostMapping("/{id}") |
29 | | - public ResponseEntity<?> registerQueue(@PathVariable Long id, @RequestBody QueueRequest queueRequest, HttpServletRequest request){ |
30 | | - String token = request.getHeader("access"); |
| 31 | + public ResponseEntity<QueueRegistrationResponse> registerQueue(@PathVariable Long id, @RequestBody QueueRequest queueRequest, HttpServletRequest request){ |
| 32 | + // 1. 대기열 등록 |
31 | 33 | QueueDto dto = queueMapper.requestToDto(queueRequest); |
32 | | - int index = queueService.registerQueue(id,dto); |
| 34 | + int waitingNumber = queueService.registerQueue(id, dto); |
| 35 | + |
| 36 | + // 2. 등록된 가게 정보 조회 |
| 37 | + HostResponse hostInfo = hostService.getHost(id); |
| 38 | + |
| 39 | + // 3. 최종 응답 생성 |
| 40 | + QueueRegistrationResponse response = QueueRegistrationResponse.builder() |
| 41 | + .message("대기열 등록에 성공했습니다.") |
| 42 | + .waitingNumber(waitingNumber) |
| 43 | + .hostInfo(hostInfo) |
| 44 | + .build(); |
33 | 45 |
|
34 | | - QueResponseDto responseDto = new QueResponseDto("대기열 등록 완료", index); |
35 | | - return ResponseEntity.status(HttpStatus.OK).body(responseDto); |
| 46 | + return ResponseEntity.status(HttpStatus.OK).body(response); |
36 | 47 | } |
37 | 48 |
|
38 | | - /** |
39 | | - * [수정] 롱폴링을 제거하고, 현재 대기 순번을 즉시 반환하도록 변경 |
40 | | - */ |
41 | 49 | @Operation(summary = "내 대기 순번 즉시 확인", description = "자신의 현재 대기 순번을 즉시 확인합니다.") |
42 | 50 | @GetMapping("/{id}/position/") |
43 | 51 | public ResponseEntity<QueResponseDto> getMyPosition( |
|
0 commit comments