package com.xhkjedu.sexam.controller.paperstudent;

import com.xhkjedu.sexam.model.exam.ESubject;
import com.xhkjedu.sexam.model.paperstudent.EPaperStudent;
import com.xhkjedu.sexam.model.paperstudent.EScanbatch;
import com.xhkjedu.sexam.service.paperstudent.EScanbatchService;
import com.xhkjedu.utils.N_Utils;
import com.xhkjedu.vo.ResultVo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Description: TODO 答题卡扫描
 * @Author: wn
 * @CreateTime: 2022-08-11  09:43
 */
@RestController
@RequestMapping("/scan")
public class EScanbatchController {
    @Resource
    private EScanbatchService eScanbatchService;

    //保持批次信息
    @PostMapping("/save")
    public ResultVo saveEscanbatch(@RequestBody EScanbatch eScanbatch) {
        N_Utils.validation(new Object[]{eScanbatch.getEpid(),"试卷id",1,eScanbatch.getDevice(),"设备",2});
        Map map = eScanbatchService.saveScanBatch(eScanbatch);
        return new ResultVo(0, "成功保存", map);
    }


    /**
     * 扫描答题卡列表
     *
     * @return com.xhkjedu.vo.ResultVo
     * @Param [subject]
     * @Author ywx
     * @Date 2022/8/11 11:28
     **/
    @PostMapping("/list_sm")
    public ResultVo listScan(@RequestBody ESubject subject) {
        Integer examid = subject.getExamid();
        N_Utils.validation(new Object[]{examid, "考试id", 1});
        Map map = eScanbatchService.listScan(examid);
        return new ResultVo(0, "获取成功", map);
    }

    /**
     * 扫描答题卡详情
     *
     * @return com.xhkjedu.vo.ResultVo
     * @Param [eps]
     * @Author ywx
     * @Date 2022/8/11 15:47
     **/
    @PostMapping("/detail")
    public ResultVo getScanDetail(@RequestBody EPaperStudent eps) {
        Integer epid = eps.getEpid();
        Integer examid = eps.getExamid();
        N_Utils.validation(new Object[]{epid, "试卷id", 1, examid, "考试id", 1});
        Map map = eScanbatchService.getScanDetail(epid, examid);
        return new ResultVo(0, "获取详情成功", map);
    }

    /**
     * @description: 试卷扫描答题卡
     * @param: [eScanbatch]
     * @return: com.xhkjedu.vo.ResultVo
     * @author: wn
     * @date:
     **/
    @PostMapping("/sp")
    public ResultVo scanPaperDetail(@RequestBody EScanbatch eScanbatch) {
        Integer epid = eScanbatch.getEpid();
        N_Utils.validation(new Object[]{epid, "试卷id", 1});
        Map map = eScanbatchService.scanPaperDetail(epid);
        return new ResultVo(0, "获取成功", map);
    }

}
