package thyyxxk.webserver.controller.examinations;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.examinations.mixlabel.MixLabel;
import thyyxxk.webserver.entity.examinations.mixlabel.MixLabelRange;
import thyyxxk.webserver.service.examinations.MixLabelPrintService;

import java.util.List;

@RestController
@RequestMapping("/mixLabelPrint")
public class MixLabelPrintController {
    private final MixLabelPrintService service;

    @Autowired
    public MixLabelPrintController(MixLabelPrintService service) {
        this.service = service;
    }

    @PassToken
    @PostMapping("/createMixLabel")
    public ResultVo<String> createMixLabel(@RequestBody MixLabelRange labelRange) {
        return service.createMixLabel(labelRange);
    }

    @GetMapping("/selectLabelRanges")
    public ResultVo<List<MixLabelRange>> selectLabelRanges() {
        return service.selectLabelRanges();
    }

    @GetMapping("/selectBeginLabel")
    public ResultVo<String> selectBeginLabel(@RequestParam("tableName") String tableName) {
        return service.selectBeginLabel(tableName);
    }

    @GetMapping("/selectLabelPrinter")
    public ResultVo<MixLabel> selectLabelPrinter(@RequestParam("tableName") String tableName,
                                                 @RequestParam("label") String label) {
        return service.selectLabelPrinter(tableName, label);
    }

    @GetMapping("/printLabel")
    public ResultVo<MixLabel> printLabel(@RequestParam("tableName") String tableName,
                                         @RequestParam("label") String label) {
        return service.printLabel(tableName, label);
    }

    @PostMapping("/reprintLabel")
    public ResultVo<MixLabel> reprintLabel(@RequestBody MixLabel printer) {
        return service.reprintLabel(printer);
    }

    @GetMapping("/allPrinted")
    public ResultVo<String> allPrinted(@RequestParam("tableName") String tableName) {
        return service.allPrinted(tableName);
    }
}
