package com.qmth.jkserver.controller.system;

import com.qmth.jkserver.enums.ExamConditionEnum;
import com.qmth.jkserver.enums.ExamFinishStatusEnum;
import com.qmth.jkserver.enums.RegistrationStatusEnum;
import com.qmth.jkserver.service.ExamProgressStatisticService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.slf4j.Logger;
import org.springframework.context.annotation.Lazy;
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;

/**
 * @Description: 考试进度前端控制器
 * @Author: CaoZixuan
 * @Date: 2021-11-15
 */
@RestController
@RequestMapping("/system/exam_progress")
public class ExamProgressStatisticController {
    private static final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(ExamProgressStatisticController.class);

    @Resource
    @Lazy
    private ExamProgressStatisticService examProgressStatisticService;

    @ApiOperation(value = "获取考试级联查询条件数据源接口")
    @RequestMapping(value = "/find_exam_condition_cascade", method = RequestMethod.POST)
    @ApiResponses({@ApiResponse(code = 200, message = "获取考试任务课程信息", response = Object.class)})
    public Object getCourseInfoByQuery(@ApiParam(value = "考试识别码") @RequestParam(required = false) String examCode,
                                       @ApiParam(value = "批次主键") @RequestParam(required = false) String batchId,
                                       @ApiParam(value = "场次主键") @RequestParam(required = false) String stageId,
                                       @ApiParam(value = "考点编号") @RequestParam(required = false) String placeCode,
                                       @ApiParam(value = "考场编号") @RequestParam(required = false) String roomCode,
                                       @ApiParam(value = "考场编号", required = true) @RequestParam ExamConditionEnum examConditionEnum) {
        return examProgressStatisticService.findExamConditionCascade(examCode, batchId, stageId, placeCode, roomCode, examConditionEnum);
    }

    @ApiOperation(value = "获取考试进度统计汇总接口")
    @RequestMapping(value = "/find_exam_progress_statistic", method = RequestMethod.POST)
    @ApiResponses({@ApiResponse(code = 200, message = "获取考试任务课程信息", response = Object.class)})
    public Object findExamProgressStatistic(@ApiParam(value = "考试识别码") @RequestParam(required = false) String examCode) {

        return examProgressStatisticService.findExamProgressStatisticByExamCode(examCode);
    }


    @ApiOperation(value = "获取考试进度统计分页查询接口")
    @RequestMapping(value = "/find_exam_progress_page", method = RequestMethod.POST)
    @ApiResponses({@ApiResponse(code = 200, message = "获取考试任务课程信息", response = Object.class)})
    public Object findExamProgressPage(@ApiParam(value = "考试编号") @RequestParam(required = false) String examCode,
                                       @ApiParam(value = "批次id") @RequestParam(required = false) String batchId,
                                       @ApiParam(value = "场次id") @RequestParam(required = false) String stageId,
                                       @ApiParam(value = "考点编号") @RequestParam(required = false) String placeCode,
                                       @ApiParam(value = "考场编号") @RequestParam(required = false) String roomCode,
                                       @ApiParam(value = "课程编号") @RequestParam(required = false) String courseCode,
                                       @ApiParam(value = "检录状态") @RequestParam(required = false) RegistrationStatusEnum registrationStatus,
                                       @ApiParam(value = "考试完成状态") @RequestParam(required = false) ExamFinishStatusEnum examFinishStatus,
                                       @ApiParam(value = "考生参数（姓名/准考证号）") @RequestParam(required = false) String examStudentParams,
                                       @ApiParam(value = "分页页数", required = true) @RequestParam int pageNumber,
                                       @ApiParam(value = "分页容量", required = true) @RequestParam int pageSize) {
        return examProgressStatisticService.findExamProgressPage(examCode, batchId, stageId, placeCode, roomCode, courseCode, registrationStatus, examFinishStatus, examStudentParams, pageNumber, pageSize);
    }
}
