package com.qmth.distributed.print.api.mark;

import com.qmth.boot.api.constant.ApiConstant;
import com.qmth.distributed.print.business.service.BasicExamService;
import com.qmth.teachcloud.common.contant.SystemConstant;
import com.qmth.teachcloud.common.entity.BasicExam;
import com.qmth.teachcloud.common.util.Result;
import com.qmth.teachcloud.common.util.ResultUtil;
import com.qmth.teachcloud.mark.service.MarkStudentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = "扫描汇总接口")
@RestController
@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_SCAN + "/exam")
public class ScanExamController {
    @Resource
    private MarkStudentService markStudentService;
    @Resource
    private BasicExamService basicExamService;

    @ApiOperation(value = "扫描汇总-答题卡扫描、签到表扫描")
    @RequestMapping(value = "card/info", method = RequestMethod.POST)
    public Result cardInfo(@ApiParam(value = "考试ID", required = true) @RequestParam Long examId,
                           @ApiParam(value = "课程代码") @RequestParam(required = false) String courseCode,
                           @ApiParam(value = "试卷编号") @RequestParam(required = false) String coursePaperId) {
        BasicExam exam = basicExamService.getById(examId);
        return ResultUtil.ok(markStudentService.getScanExamInfo(exam, courseCode, coursePaperId));
    }

    @ApiOperation(value = "扫描汇总-数据校对")
    @RequestMapping(value = "check/info", method = RequestMethod.POST)
    public Result checkInfo(@ApiParam(value = "考试ID", required = true) @RequestParam Long examId,
                            @ApiParam(value = "课程代码") @RequestParam(required = false) String courseCode,
                            @ApiParam(value = "试卷编号") @RequestParam(required = false) String coursePaperId) {
        BasicExam exam = basicExamService.getById(examId);
        return ResultUtil.ok(markStudentService.checkInfo(exam, courseCode, coursePaperId));
    }
}
