package com.lanyuanxiaoyao.service.web.controller;

import com.lanyuanxiaoyao.service.configuration.entity.queue.QueueItem;
import com.lanyuanxiaoyao.service.forest.service.QueueService;
import com.lanyuanxiaoyao.service.web.controller.base.AmisCrudResponse;
import com.lanyuanxiaoyao.service.web.controller.base.AmisResponse;
import com.lanyuanxiaoyao.service.web.controller.base.BaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 队列接口
 *
 * @author lanyuanxiaoyao
 * @date 2023-05-07
 */
@RestController
@RequestMapping("queue")
public class QueueController extends BaseController {
    private static final Logger logger = LoggerFactory.getLogger(QueueController.class);

    private final QueueService queueService;

    @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
    public QueueController(QueueService queueService) {
        this.queueService = queueService;
    }

    @GetMapping("all")
    public AmisCrudResponse all(@RequestParam("name") String name) {
        return AmisResponse.responseCrudData(queueService.all(name).toSortedList(QueueItem::compareTo));
    }
}
