feat(queue): 队列接口统一改为query
This commit is contained in:
@@ -42,200 +42,200 @@ public class DequeController implements QueueOperator {
|
||||
return Constants.DEQUE_MAP.keys();
|
||||
}
|
||||
|
||||
@GetMapping("/all/{name}")
|
||||
@GetMapping("/all")
|
||||
@Override
|
||||
public List<QueueItem<?>> all(@PathVariable("name") String name) {
|
||||
public List<QueueItem<?>> all(@RequestParam("name") String name) {
|
||||
return makeReturn(name, ArrayList::new);
|
||||
}
|
||||
|
||||
@PostMapping("/add_first/{name}")
|
||||
public void addFirst(@PathVariable("name") String name, @RequestBody QueueItem<?> data) {
|
||||
@PostMapping("/add_first")
|
||||
public void addFirst(@RequestParam("name") String name, @RequestBody QueueItem<?> data) {
|
||||
makeVoid(name, deque -> deque.addFirst(data));
|
||||
}
|
||||
|
||||
@PostMapping("/add_last/{name}")
|
||||
public void addLast(@PathVariable("name") String name, @RequestBody QueueItem<?> data) {
|
||||
@PostMapping("/add_last")
|
||||
public void addLast(@RequestParam("name") String name, @RequestBody QueueItem<?> data) {
|
||||
makeVoid(name, deque -> deque.addLast(data));
|
||||
}
|
||||
|
||||
@PostMapping("/offer_first/{name}")
|
||||
public Boolean offerFirst(@PathVariable("name") String name, @RequestBody QueueItem<?> data) {
|
||||
@PostMapping("/offer_first")
|
||||
public Boolean offerFirst(@RequestParam("name") String name, @RequestBody QueueItem<?> data) {
|
||||
return makeReturn(name, deque -> deque.offerFirst(data));
|
||||
}
|
||||
|
||||
@PostMapping("/offer_last/{name}")
|
||||
public Boolean offerLast(@PathVariable("name") String name, @RequestBody QueueItem<?> data) {
|
||||
@PostMapping("/offer_last")
|
||||
public Boolean offerLast(@RequestParam("name") String name, @RequestBody QueueItem<?> data) {
|
||||
return makeReturn(name, deque -> deque.offerLast(data));
|
||||
}
|
||||
|
||||
@GetMapping("/remove_first/{name}")
|
||||
public QueueItem<?> removeFirst(@PathVariable("name") String name) {
|
||||
@GetMapping("/remove_first")
|
||||
public QueueItem<?> removeFirst(@RequestParam("name") String name) {
|
||||
return makeReturn(name, ConcurrentLinkedDeque::removeFirst);
|
||||
}
|
||||
|
||||
@GetMapping("/remove_last/{name}")
|
||||
public QueueItem<?> removeLast(@PathVariable("name") String name) {
|
||||
@GetMapping("/remove_last")
|
||||
public QueueItem<?> removeLast(@RequestParam("name") String name) {
|
||||
return makeReturn(name, ConcurrentLinkedDeque::removeLast);
|
||||
}
|
||||
|
||||
@GetMapping("/poll_first/{name}")
|
||||
public QueueItem<?> pollFirst(@PathVariable("name") String name) {
|
||||
@GetMapping("/poll_first")
|
||||
public QueueItem<?> pollFirst(@RequestParam("name") String name) {
|
||||
return makeReturn(name, ConcurrentLinkedDeque::pollFirst);
|
||||
}
|
||||
|
||||
@GetMapping("/poll_last/{name}")
|
||||
public QueueItem<?> pollLast(@PathVariable("name") String name) {
|
||||
@GetMapping("/poll_last")
|
||||
public QueueItem<?> pollLast(@RequestParam("name") String name) {
|
||||
return makeReturn(name, ConcurrentLinkedDeque::pollLast);
|
||||
}
|
||||
|
||||
@GetMapping("/get_first/{name}")
|
||||
public QueueItem<?> getFirst(@PathVariable("name") String name) {
|
||||
@GetMapping("/get_first")
|
||||
public QueueItem<?> getFirst(@RequestParam("name") String name) {
|
||||
return makeReturn(name, ConcurrentLinkedDeque::getFirst);
|
||||
}
|
||||
|
||||
@GetMapping("/get_last/{name}")
|
||||
public QueueItem<?> getLast(@PathVariable("name") String name) {
|
||||
@GetMapping("/get_last")
|
||||
public QueueItem<?> getLast(@RequestParam("name") String name) {
|
||||
return makeReturn(name, ConcurrentLinkedDeque::getLast);
|
||||
}
|
||||
|
||||
@GetMapping("/peek_first/{name}")
|
||||
public QueueItem<?> peekFirst(@PathVariable("name") String name) {
|
||||
@GetMapping("/peek_first")
|
||||
public QueueItem<?> peekFirst(@RequestParam("name") String name) {
|
||||
return makeReturn(name, ConcurrentLinkedDeque::peekFirst);
|
||||
}
|
||||
|
||||
@GetMapping("/peek_last/{name}")
|
||||
public QueueItem<?> peekLast(@PathVariable("name") String name) {
|
||||
@GetMapping("/peek_last")
|
||||
public QueueItem<?> peekLast(@RequestParam("name") String name) {
|
||||
return makeReturn(name, ConcurrentLinkedDeque::peekLast);
|
||||
}
|
||||
|
||||
@PostMapping("/remove_first_occurrence/{name}")
|
||||
public Boolean removeFirstOccurrence(@PathVariable("name") String name, @RequestBody String data) {
|
||||
@PostMapping("/remove_first_occurrence")
|
||||
public Boolean removeFirstOccurrence(@RequestParam("name") String name, @RequestBody String data) {
|
||||
return makeReturn(name, deque -> deque.removeFirstOccurrence(data));
|
||||
}
|
||||
|
||||
@GetMapping("/remove_first_occurrence_id/{name}/{id}")
|
||||
public Boolean removeFirstOccurrenceId(@PathVariable("name") String name, @PathVariable("id") String id) {
|
||||
@GetMapping("/remove_first_occurrence_id")
|
||||
public Boolean removeFirstOccurrenceId(@RequestParam("name") String name, @RequestParam("id") String id) {
|
||||
return makeReturn(name, deque -> deque.removeFirstOccurrence(new QueueItem<>(id)));
|
||||
}
|
||||
|
||||
@PostMapping("/remove_last_occurrence/{name}")
|
||||
public Boolean removeLastOccurrence(@PathVariable("name") String name, @RequestBody String data) {
|
||||
@PostMapping("/remove_last_occurrence")
|
||||
public Boolean removeLastOccurrence(@RequestParam("name") String name, @RequestBody String data) {
|
||||
return makeReturn(name, deque -> deque.removeLastOccurrence(data));
|
||||
}
|
||||
|
||||
@GetMapping("/remove_last_occurrence_id/{name}/{id}")
|
||||
public Boolean removeLastOccurrenceId(@PathVariable("name") String name, @PathVariable("id") String id) {
|
||||
@GetMapping("/remove_last_occurrence_id")
|
||||
public Boolean removeLastOccurrenceId(@RequestParam("name") String name, @RequestParam("id") String id) {
|
||||
return makeReturn(name, deque -> deque.removeLastOccurrence(new QueueItem<>(id)));
|
||||
}
|
||||
|
||||
@PostMapping("/add/{name}")
|
||||
public Boolean add(@PathVariable("name") String name, @RequestBody QueueItem<?> data) {
|
||||
@PostMapping("/add")
|
||||
public Boolean add(@RequestParam("name") String name, @RequestBody QueueItem<?> data) {
|
||||
return makeReturn(name, deque -> deque.add(data));
|
||||
}
|
||||
|
||||
@PostMapping("/offer/{name}")
|
||||
public Boolean offer(@PathVariable("name") String name, @RequestBody QueueItem<?> data) {
|
||||
@PostMapping("/offer")
|
||||
public Boolean offer(@RequestParam("name") String name, @RequestBody QueueItem<?> data) {
|
||||
return makeReturn(name, deque -> deque.offer(data));
|
||||
}
|
||||
|
||||
@GetMapping("/remove/{name}")
|
||||
public QueueItem<?> remove(@PathVariable("name") String name) {
|
||||
@GetMapping("/remove")
|
||||
public QueueItem<?> remove(@RequestParam("name") String name) {
|
||||
return makeReturn(name, ConcurrentLinkedDeque::remove);
|
||||
}
|
||||
|
||||
@GetMapping("/poll/{name}")
|
||||
public QueueItem<?> poll(@PathVariable("name") String name) {
|
||||
@GetMapping("/poll")
|
||||
public QueueItem<?> poll(@RequestParam("name") String name) {
|
||||
return makeReturn(name, ConcurrentLinkedDeque::poll);
|
||||
}
|
||||
|
||||
@GetMapping("/element/{name}")
|
||||
public QueueItem<?> element(@PathVariable("name") String name) {
|
||||
@GetMapping("/element")
|
||||
public QueueItem<?> element(@RequestParam("name") String name) {
|
||||
return makeReturn(name, ConcurrentLinkedDeque::element);
|
||||
}
|
||||
|
||||
@GetMapping("/peek/{name}")
|
||||
public QueueItem<?> peek(@PathVariable("name") String name) {
|
||||
@GetMapping("/peek")
|
||||
public QueueItem<?> peek(@RequestParam("name") String name) {
|
||||
return makeReturn(name, ConcurrentLinkedDeque::peek);
|
||||
}
|
||||
|
||||
@PostMapping("/push/{name}")
|
||||
public void push(@PathVariable("name") String name, @RequestBody QueueItem<?> data) {
|
||||
@PostMapping("/push")
|
||||
public void push(@RequestParam("name") String name, @RequestBody QueueItem<?> data) {
|
||||
makeVoid(name, deque -> deque.push(data));
|
||||
}
|
||||
|
||||
@GetMapping("/pop/{name}")
|
||||
public QueueItem<?> pop(@PathVariable("name") String name) {
|
||||
@GetMapping("/pop")
|
||||
public QueueItem<?> pop(@RequestParam("name") String name) {
|
||||
return makeReturn(name, ConcurrentLinkedDeque::pop);
|
||||
}
|
||||
|
||||
@PostMapping("/remove/{name}")
|
||||
public Boolean remove(@PathVariable("name") String name, @RequestBody QueueItem<?> data) {
|
||||
@PostMapping("/remove")
|
||||
public Boolean remove(@RequestParam("name") String name, @RequestBody QueueItem<?> data) {
|
||||
return makeReturn(name, deque -> deque.remove(data));
|
||||
}
|
||||
|
||||
@GetMapping("/remove_id/{name}/{id}")
|
||||
public Boolean removeId(@PathVariable("name") String name, @PathVariable("id") String id) {
|
||||
@GetMapping("/remove_id")
|
||||
public Boolean removeId(@RequestParam("name") String name, @RequestParam("id") String id) {
|
||||
return makeReturn(name, deque -> deque.remove(new QueueItem<>(id)));
|
||||
}
|
||||
|
||||
@PostMapping("/contains_all/{name}")
|
||||
public Boolean containsAll(@PathVariable("name") String name, @RequestBody List<QueueItem<?>> data) {
|
||||
@PostMapping("/contains_all")
|
||||
public Boolean containsAll(@RequestParam("name") String name, @RequestBody List<QueueItem<?>> data) {
|
||||
return makeReturn(name, deque -> deque.containsAll(data));
|
||||
}
|
||||
|
||||
@PostMapping("/contains_all_id/{name}")
|
||||
public Boolean containsAllId(@PathVariable("name") String name, @RequestBody List<String> ids) {
|
||||
@PostMapping("/contains_all_id")
|
||||
public Boolean containsAllId(@RequestParam("name") String name, @RequestBody List<String> ids) {
|
||||
List<QueueItem<?>> containsItems = ids.stream().map(QueueItem::new).collect(Collectors.toList());
|
||||
return makeReturn(name, deque -> deque.containsAll(containsItems));
|
||||
}
|
||||
|
||||
@PostMapping("/add_all/{name}")
|
||||
public Boolean addAll(@PathVariable("name") String name, @RequestBody List<QueueItem<?>> data) {
|
||||
@PostMapping("/add_all")
|
||||
public Boolean addAll(@RequestParam("name") String name, @RequestBody List<QueueItem<?>> data) {
|
||||
return makeReturn(name, deque -> deque.addAll(data));
|
||||
}
|
||||
|
||||
@PostMapping("/remove_all/{name}")
|
||||
public Boolean removeAll(@PathVariable("name") String name, @RequestBody List<QueueItem<?>> data) {
|
||||
@PostMapping("/remove_all")
|
||||
public Boolean removeAll(@RequestParam("name") String name, @RequestBody List<QueueItem<?>> data) {
|
||||
return makeReturn(name, deque -> deque.removeAll(data));
|
||||
}
|
||||
|
||||
@PostMapping("/remove_all_id/{name}")
|
||||
public Boolean removeAllId(@PathVariable("name") String name, @RequestBody List<String> ids) {
|
||||
@PostMapping("/remove_all_id")
|
||||
public Boolean removeAllId(@RequestParam("name") String name, @RequestBody List<String> ids) {
|
||||
return makeReturn(name, deque -> deque.removeIf(item -> ids.contains(item.getId())));
|
||||
}
|
||||
|
||||
@GetMapping("/remove_all_id/{name}/{id}")
|
||||
public Boolean removeAllId(@PathVariable("name") String name, @PathVariable String id) {
|
||||
@GetMapping("/remove_all_id")
|
||||
public Boolean removeAllId(@RequestParam("name") String name, @RequestParam String id) {
|
||||
return makeReturn(name, deque -> deque.removeIf(item -> item.getId().equals(id)));
|
||||
}
|
||||
|
||||
@PostMapping("/retain_all/{name}")
|
||||
public Boolean retainAll(@PathVariable("name") String name, @RequestBody List<QueueItem<?>> data) {
|
||||
@PostMapping("/retain_all")
|
||||
public Boolean retainAll(@RequestParam("name") String name, @RequestBody List<QueueItem<?>> data) {
|
||||
return makeReturn(name, deque -> deque.retainAll(data));
|
||||
}
|
||||
|
||||
@GetMapping("/clear/{name}")
|
||||
public void clear(@PathVariable("name") String name) {
|
||||
@GetMapping("/clear")
|
||||
public void clear(@RequestParam("name") String name) {
|
||||
makeVoid(name, ConcurrentLinkedDeque::clear);
|
||||
}
|
||||
|
||||
@PostMapping("/contains/{name}")
|
||||
public Boolean contains(@PathVariable("name") String name, @RequestBody QueueItem<?> data) {
|
||||
@PostMapping("/contains")
|
||||
public Boolean contains(@RequestParam("name") String name, @RequestBody QueueItem<?> data) {
|
||||
return makeReturn(name, deque -> deque.contains(data));
|
||||
}
|
||||
|
||||
@GetMapping("/contains_id/{name}/{id}")
|
||||
public Boolean containsId(@PathVariable("name") String name, @PathVariable("id") String id) {
|
||||
@GetMapping("/contains_id")
|
||||
public Boolean containsId(@RequestParam("name") String name, @RequestParam("id") String id) {
|
||||
return makeReturn(name, deque -> deque.contains(new QueueItem<>(id)));
|
||||
}
|
||||
|
||||
@GetMapping("/size/{name}")
|
||||
public Integer size(@PathVariable("name") String name) {
|
||||
@GetMapping("/size")
|
||||
public Integer size(@RequestParam("name") String name) {
|
||||
return makeReturn(name, ConcurrentLinkedDeque::size);
|
||||
}
|
||||
|
||||
@GetMapping("/is_empty/{name}")
|
||||
public Boolean isEmpty(@PathVariable("name") String name) {
|
||||
@GetMapping("/is_empty")
|
||||
public Boolean isEmpty(@RequestParam("name") String name) {
|
||||
return makeReturn(name, ConcurrentLinkedDeque::isEmpty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,100 +40,100 @@ public class QueueController implements QueueOperator {
|
||||
return Constants.QUEUE_MAP.keys();
|
||||
}
|
||||
|
||||
@GetMapping("/all/{name}")
|
||||
@GetMapping("/all")
|
||||
@Override
|
||||
public List<QueueItem<?>> all(@PathVariable("name") String name) {
|
||||
public List<QueueItem<?>> all(@RequestParam("name") String name) {
|
||||
return makeReturn(name, ArrayList::new);
|
||||
}
|
||||
|
||||
@GetMapping("/size/{name}")
|
||||
public Integer size(@PathVariable("name") String name) {
|
||||
@GetMapping("/size")
|
||||
public Integer size(@RequestParam("name") String name) {
|
||||
return makeReturn(name, PriorityBlockingQueue::size);
|
||||
}
|
||||
|
||||
@GetMapping("/is_empty/{name}")
|
||||
public Boolean isEmpty(@PathVariable("name") String name) {
|
||||
@GetMapping("/is_empty")
|
||||
public Boolean isEmpty(@RequestParam("name") String name) {
|
||||
return makeReturn(name, PriorityBlockingQueue::isEmpty);
|
||||
}
|
||||
|
||||
@PostMapping("/contains/{name}")
|
||||
public Boolean contains(@PathVariable("name") String name, @RequestBody QueueItem<?> data) {
|
||||
@PostMapping("/contains")
|
||||
public Boolean contains(@RequestParam("name") String name, @RequestBody QueueItem<?> data) {
|
||||
return makeReturn(name, queue -> queue.contains(data));
|
||||
}
|
||||
|
||||
@GetMapping("/contains/{name}/{id}")
|
||||
public Boolean containsId(@PathVariable("name") String name, @PathVariable("id") String id) {
|
||||
@GetMapping("/contains")
|
||||
public Boolean containsId(@RequestParam("name") String name, @RequestParam("id") String id) {
|
||||
return makeReturn(name, queue -> queue.contains(new QueueItem<>(id)));
|
||||
}
|
||||
|
||||
@PostMapping("/add/{name}")
|
||||
public Boolean add(@PathVariable("name") String name, @RequestBody QueueItem<?> data) {
|
||||
@PostMapping("/add")
|
||||
public Boolean add(@RequestParam("name") String name, @RequestBody QueueItem<?> data) {
|
||||
return makeReturn(name, queue -> queue.add(data));
|
||||
}
|
||||
|
||||
@PostMapping("/remove/{name}")
|
||||
public Boolean remove(@PathVariable("name") String name, @RequestBody QueueItem<?> data) {
|
||||
@PostMapping("/remove")
|
||||
public Boolean remove(@RequestParam("name") String name, @RequestBody QueueItem<?> data) {
|
||||
return makeReturn(name, queue -> queue.remove(data));
|
||||
}
|
||||
|
||||
@GetMapping("/remove_id/{name}/{id}")
|
||||
public Boolean remove(@PathVariable("name") String name, @PathVariable("id") String id) {
|
||||
@GetMapping("/remove_id")
|
||||
public Boolean remove(@RequestParam("name") String name, @RequestParam("id") String id) {
|
||||
return makeReturn(name, queue -> queue.remove(new QueueItem<>(id)));
|
||||
}
|
||||
|
||||
@PostMapping("/contains_all/{name}")
|
||||
public Boolean containsAll(@PathVariable("name") String name, @RequestBody List<QueueItem<?>> data) {
|
||||
@PostMapping("/contains_all")
|
||||
public Boolean containsAll(@RequestParam("name") String name, @RequestBody List<QueueItem<?>> data) {
|
||||
return makeReturn(name, queue -> queue.containsAll(data));
|
||||
}
|
||||
|
||||
@PostMapping("/contains_all_id/{name}")
|
||||
public Boolean containsAllId(@PathVariable("name") String name, @RequestBody List<String> ids) {
|
||||
@PostMapping("/contains_all_id")
|
||||
public Boolean containsAllId(@RequestParam("name") String name, @RequestBody List<String> ids) {
|
||||
List<QueueItem<?>> containsItems = ids.stream().map(QueueItem::new).collect(Collectors.toList());
|
||||
return makeReturn(name, queue -> queue.containsAll(containsItems));
|
||||
}
|
||||
|
||||
@PostMapping("/add_all/{name}")
|
||||
public Boolean addAll(@PathVariable("name") String name, @RequestBody List<QueueItem<?>> data) {
|
||||
@PostMapping("/add_all")
|
||||
public Boolean addAll(@RequestParam("name") String name, @RequestBody List<QueueItem<?>> data) {
|
||||
return makeReturn(name, queue -> queue.addAll(data));
|
||||
}
|
||||
|
||||
@PostMapping("/remove_all/{name}")
|
||||
public Boolean removeAll(@PathVariable("name") String name, @RequestBody List<QueueItem<?>> data) {
|
||||
@PostMapping("/remove_all")
|
||||
public Boolean removeAll(@RequestParam("name") String name, @RequestBody List<QueueItem<?>> data) {
|
||||
return makeReturn(name, queue -> queue.removeAll(data));
|
||||
}
|
||||
|
||||
@PostMapping("/remove_all_id/{name}")
|
||||
public Boolean removeAllId(@PathVariable("name") String name, @RequestBody List<String> ids) {
|
||||
@PostMapping("/remove_all_id")
|
||||
public Boolean removeAllId(@RequestParam("name") String name, @RequestBody List<String> ids) {
|
||||
return makeReturn(name, queue -> queue.removeIf(item -> ids.contains(item.getId())));
|
||||
}
|
||||
|
||||
@GetMapping("/remove_all_id/{name}/{id}")
|
||||
public Boolean removeAllId(@PathVariable("name") String name, @PathVariable("id") String id) {
|
||||
@GetMapping("/remove_all_id")
|
||||
public Boolean removeAllId(@RequestParam("name") String name, @RequestParam("id") String id) {
|
||||
return makeReturn(name, queue -> queue.removeIf(item -> item.getId().equals(id)));
|
||||
}
|
||||
|
||||
@PostMapping("/retain_all/{name}")
|
||||
public Boolean retainAll(@PathVariable("name") String name, @RequestBody List<QueueItem<?>> data) {
|
||||
@PostMapping("/retain_all")
|
||||
public Boolean retainAll(@RequestParam("name") String name, @RequestBody List<QueueItem<?>> data) {
|
||||
return makeReturn(name, queue -> queue.retainAll(data));
|
||||
}
|
||||
|
||||
@GetMapping("/clear/{name}")
|
||||
public void clear(@PathVariable("name") String name) {
|
||||
@GetMapping("/clear")
|
||||
public void clear(@RequestParam("name") String name) {
|
||||
makeVoid(name, PriorityBlockingQueue::clear);
|
||||
}
|
||||
|
||||
@PostMapping("/offer/{name}")
|
||||
public Boolean offer(@PathVariable("name") String name, @RequestBody QueueItem<?> data) {
|
||||
@PostMapping("/offer")
|
||||
public Boolean offer(@RequestParam("name") String name, @RequestBody QueueItem<?> data) {
|
||||
return makeReturn(name, queue -> queue.offer(data));
|
||||
}
|
||||
|
||||
@GetMapping("/remove/{name}")
|
||||
public QueueItem<?> remove(@PathVariable("name") String name) {
|
||||
@GetMapping("/remove")
|
||||
public QueueItem<?> remove(@RequestParam("name") String name) {
|
||||
return makeReturn(name, PriorityBlockingQueue::remove);
|
||||
}
|
||||
|
||||
@GetMapping("/poll/{name}")
|
||||
public QueueItem<?> poll(@PathVariable("name") String name) {
|
||||
@GetMapping("/poll")
|
||||
public QueueItem<?> poll(@RequestParam("name") String name) {
|
||||
return makeReturn(name, queue -> {
|
||||
try {
|
||||
return queue.poll(Constants.POLL_TIMEOUT, Constants.TIMEOUT_UNIT);
|
||||
@@ -143,13 +143,13 @@ public class QueueController implements QueueOperator {
|
||||
});
|
||||
}
|
||||
|
||||
@GetMapping("/element/{name}")
|
||||
public QueueItem<?> element(@PathVariable("name") String name) {
|
||||
@GetMapping("/element")
|
||||
public QueueItem<?> element(@RequestParam("name") String name) {
|
||||
return makeReturn(name, PriorityBlockingQueue::element);
|
||||
}
|
||||
|
||||
@GetMapping("/peek/{name}")
|
||||
public QueueItem<?> peek(@PathVariable("name") String name) {
|
||||
@GetMapping("/peek")
|
||||
public QueueItem<?> peek(@RequestParam("name") String name) {
|
||||
return makeReturn(name, PriorityBlockingQueue::peek);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user