-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathQueueController.java
More file actions
57 lines (48 loc) · 2.06 KB
/
QueueController.java
File metadata and controls
57 lines (48 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.example.restservice.controller;
import com.example.restservice.controller.model.queue.*;
import com.example.restservice.dao.CustomQuestions;
import com.example.restservice.service.QueueService;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@RestController
@RequestMapping("/v1")
@RequiredArgsConstructor
public class QueueController {
private final QueueService queueService;
@PostMapping(path = "/queue")
public ResponseEntity<CreateQueueResponse> createQueue(
@Valid @RequestBody CreateQueueRequest createQueueRequest) {
return ResponseEntity.ok(queueService.createQueue(createQueueRequest));
}
@GetMapping(path = "/queues")
public ResponseEntity<MyQueuesResponse> getMyQueues() {
return ResponseEntity.ok(queueService.getMyQueues());
}
@GetMapping(path = "/queue/{queueId}")
public ResponseEntity<QueueDetailsResponse> getQueueDetails(
@PathVariable("queueId") String queueId) {
return ResponseEntity.ok(queueService.getQueueDetails(queueId));
}
@GetMapping(path = "/queue/status")
public ResponseEntity<QueueStatusResponse> getQueueStatus(
@RequestParam(required = false) String queueId,
@RequestParam(required = false) String queueName) {
if (queueId != null) {
return ResponseEntity.ok(queueService.getQueueStatus(queueId));
} else if (queueName != null) {
return ResponseEntity.ok(queueService.getQueueStatusByName(queueName));
} else {
return new ResponseEntity(HttpStatus.BAD_REQUEST); // Todo Give reason
}
}
@PostMapping(path = "/queue/{queueId}/custom-questions")
public ResponseEntity<CustomQuestions> createCustomQuestions(
@PathVariable("queueId") String queueId,
@RequestBody String customQuestions) throws JsonProcessingException {
return ResponseEntity.ok(queueService.createCustomQuestions(queueId ,customQuestions));
}
}