package com.mortals.xhx.busiz.handler.impl;

import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.xhx.busiz.handler.BaseReqHandler;
import com.mortals.xhx.busiz.rsp.ApiResp;
import com.mortals.xhx.busiz.rsp.PrintListResp;
import com.mortals.xhx.module.print.model.Printer;
import com.mortals.xhx.module.print.service.PrintService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 打印机打印队列
 *
 * @author:
 * @date: 2023/1/5 22:25
 */
@Service
@Slf4j
public class BusizPrintQueueReqHandler extends BaseReqHandler<String, Void> {

    @Autowired
    private PrintService printService;

    @Override
    protected ApiResp<Void> handle(String printReq) throws AppException {
        Rest<List<Printer>> rest = printService.getPrintList();
        PrintListResp printListResp = new PrintListResp();
        printListResp.setStatus(PrintListResp.SUCCESS);
        printListResp.setMessage("success");
        printListResp.setPrinterList(rest.getData());
        log.info("【打印列表】【执行响应】-->{}", JSON.toJSONString(printListResp));
        return printListResp;
    }

    @Override
    protected void validData(String request) throws IllegalArgumentException {

    }


}
