//package com.backendsys.modules.queue.controller;
//
//import com.backendsys.modules.common.config.security.annotations.Anonymous;
//import com.backendsys.modules.queue.entity.QueuePosition;
//import com.backendsys.modules.queue.entity.QueueRequest;
//import com.backendsys.modules.queue.service.QueueService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//
//@RestController
//public class QueueController {
//
//    @Autowired
//    private QueueService queueService;
//
//    /**
//     * 提交请求并加入队列
//     */
//    @Anonymous
//    @PostMapping("/api/queue/submit")
//    public String submitRequest() {
//        QueueRequest request = new QueueRequest();
//        int position = queueService.enqueue("taskQueue", request);
//        return "Your request has been submitted. You are at position " + position + " in the queue. request id: " + request.getId();
//    }
//
//    /**
//     * 启动处理队列中的请求
//     */
//    @Anonymous
//    @GetMapping("/api/queue/startProcessing")
//    public String startProcessing() {
//        queueService.startProcessing("taskQueue");
//        return "Processing has started.";
//    }
//
//    /**
//     * 查询队列
//     */
//    @Anonymous
//    @GetMapping("/api/queue/position")
//    public String getPosition(@RequestParam String requestId) {
//        QueuePosition positionInfo = queueService.getPosition("taskQueue", requestId);
//        if (positionInfo.getPosition() == -1) {
//            return "Request not found.";
//        } else {
//            return "Your request is at position " + positionInfo.getPosition() + " out of " + positionInfo.getTotal() + " in the queue.";
//        }
//    }
//
//}
