package com.sundot.airport.web.controller.exam;

import com.sundot.airport.exam.common.ClientTypeConstant;
import com.sundot.airport.exam.common.HttpResult;
import com.sundot.airport.exam.common.PageData;
import com.sundot.airport.exam.logic.eighteen.model.params.*;
import com.sundot.airport.exam.logic.eighteen.model.result.*;
import com.sundot.airport.exam.logic.eighteen.model.result.subresult.ItemIn18ExamRecordListResult;
import com.sundot.airport.exam.logic.eighteen.service.EighteenService;
import com.sundot.airport.exam.logic.eighteen.service.ExamOnlineService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <b>功能名：</b>EighteenController<br>
 * <b>说明：</b> 十八大接口控制层 <br>
 * <b>著作权：</b> Copyright (C) 2021 HUIFANEDU  CORPORATION<br>
 * <b>修改履历：
 *
 * @author 2021-06-04 huifan
 */
@RestController
@RequestMapping("/v1/cs/app/eighteen")
public class EighteenController {

    @Resource
    private EighteenService eighteenService;
    @Resource
    private ExamOnlineService examOnlineService;



    /**
     * <b>方法名: </b> getExam <br>
     * <b>说明: </b> 查询考试基本信息 <br>
     *
     * @param param Get18ExamIntroParams 查询考试基本信息参数类
     * @return HttpResult<Get18ExamIntroResult>
     * <b>修改履历: </b>
     * @author 2021/7/5 Mokou
     */
    @PostMapping("/get_exam_intro")
    public HttpResult<Get18ExamIntroResult> getExamIntro(@Validated @RequestBody Get18ExamIntroParams param) {
        return eighteenService.getExamIntro(param);
    }

    /**
     * <b>方法名: </b> applyExam <br>
     * <b>说明: </b> 开始考试 <br>
     *
     * @param token java.lang.String token信息
     * @param param com.sundot.airport.logic.eighteen.model.params.ExamRecAddParam 在线测试用户获取考试基本信息和试题请求参数
     * @return com.huifanedu.kernel.model.response.HttpResult<com.sundot.airport.logic.eighteen.model.result.Check18VideoFinishResult><br>
     * <b>修改履历: </b>
     * @author 2021/7/5 liangxiao
     */
    @PostMapping("/get_exam")

    public HttpResult<ExamGetResult> applyExam(@RequestHeader(value="Authorization", required=true) String token,
                                               @Validated @RequestBody ExamRecAddParam param) {
        // 十八大对应的院长端
        param.setClientType(ClientTypeConstant.CLIENT_TYPE_KG_APP);
        return examOnlineService.applyExam(token, param);
    }

    /**
     * <b>方法名: </b> getExamRecordList <br>
     * <b>说明: </b> 查询测试记录列表 <br>
     *
     * @param param Get18ExamRecordListParams 查询测试记录列表参数类
     * @return HttpResult<PageData < ItemIn18ExamRecordListResult>>
     * <b>修改履历: </b>
     * @author 2021/7/5 Mokou
     */
    @PostMapping("/get_exam_record_list")
    public HttpResult<PageData<ItemIn18ExamRecordListResult>> getExamRecordList(@Validated @RequestBody Get18ExamRecordListParams param) {
        return eighteenService.getExamRecordList(param);
    }

    /**
     * <b>方法名: </b> getExamRecord <br>
     * <b>说明: </b> 查询测试记录详情 <br>
     *
     * @param param Get18ExamRecordParams 查询测试记录详情参数类
     * @return HttpResult<ItemIn18ExamRecordResult>
     * <b>修改履历: </b>
     * @author 2021/7/5 Mokou
     */
    @PostMapping("/get_exam_record")
    public HttpResult<ItemIn18ExamRecordResult> getExamRecord(@Validated @RequestBody Get18ExamRecordParams param) {
        return eighteenService.getExamRecord(param);
    }

    /**
     * <b>方法名: </b> submitExam <br>
     * <b>说明: </b> 提交考试 <br>
     *
     * @param param SubmitExamParam 提交考试参数类
     * @return HttpResult<SubmitExamResult>
     * <b>修改履历: </b>
     * @author 2021/7/6 Mokou
     */
    @PostMapping("/submit_exam")
    public HttpResult<SubmitExamResult> submitExam(@Validated @RequestBody SubmitExamParam param) {
        return eighteenService.submitExam(param);
    }
}
