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.CaptureResp;
import com.mortals.xhx.busiz.rsp.PrintListResp;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.capture.model.File;
import com.mortals.xhx.module.capture.service.CaptureService;
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: zxfei
 * @date: 2024/1/2 9:51
 */
@Service
@Slf4j
public class BusizCaptureReqHandler extends BaseReqHandler<String, Void> {

    @Autowired
    private CaptureService captureService;

    @Override
    protected ApiResp<Void> handle(String printReq) throws AppException {
        Rest<List<File>> rest = captureService.getCapture();
        CaptureResp captureResp = new CaptureResp();
        if (rest.getCode() == YesNoEnum.YES.getValue()) {
            captureResp.setStatus(CaptureResp.SUCCESS);
            captureResp.setMessage(rest.getMsg());
            captureResp.setFilelist(rest.getData());
        } else {
            captureResp.setStatus(CaptureResp.FAIL);
            captureResp.setMessage("高拍仪获取照片失败！");
        }
        log.info("【高拍仪】【执行响应】-->{}", JSON.toJSONString(captureResp));
        return captureResp;
    }

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

    }


}
