QueueController.java 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //package com.backendsys.modules.queue.controller;
  2. //
  3. //import com.backendsys.modules.common.config.security.annotations.Anonymous;
  4. //import com.backendsys.modules.queue.entity.QueuePosition;
  5. //import com.backendsys.modules.queue.entity.QueueRequest;
  6. //import com.backendsys.modules.queue.service.QueueService;
  7. //import org.springframework.beans.factory.annotation.Autowired;
  8. //import org.springframework.web.bind.annotation.*;
  9. //
  10. //@RestController
  11. //public class QueueController {
  12. //
  13. // @Autowired
  14. // private QueueService queueService;
  15. //
  16. // /**
  17. // * 提交请求并加入队列
  18. // */
  19. // @Anonymous
  20. // @PostMapping("/api/queue/submit")
  21. // public String submitRequest() {
  22. // QueueRequest request = new QueueRequest();
  23. // int position = queueService.enqueue("taskQueue", request);
  24. // return "Your request has been submitted. You are at position " + position + " in the queue. request id: " + request.getId();
  25. // }
  26. //
  27. // /**
  28. // * 启动处理队列中的请求
  29. // */
  30. // @Anonymous
  31. // @GetMapping("/api/queue/startProcessing")
  32. // public String startProcessing() {
  33. // queueService.startProcessing("taskQueue");
  34. // return "Processing has started.";
  35. // }
  36. //
  37. // /**
  38. // * 查询队列
  39. // */
  40. // @Anonymous
  41. // @GetMapping("/api/queue/position")
  42. // public String getPosition(@RequestParam String requestId) {
  43. // QueuePosition positionInfo = queueService.getPosition("taskQueue", requestId);
  44. // if (positionInfo.getPosition() == -1) {
  45. // return "Request not found.";
  46. // } else {
  47. // return "Your request is at position " + positionInfo.getPosition() + " out of " + positionInfo.getTotal() + " in the queue.";
  48. // }
  49. // }
  50. //
  51. //}