package com.xhkjedu.sexam.controller.report;

import com.xhkjedu.sexam.service.report.EReportStudentService;
import com.xhkjedu.sexam.vo.report.ReportParamsVo;
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.List;
import java.util.Map;

/**
 * @author ywx
 * @classname EReportStudentController
 * @description 学生报告
 * @date 2022/8/8 9:44
 **/
@RestController
@RequestMapping("erstu")
public class EReportStudentController {
    @Resource
    private EReportStudentService eReportStudentService;

    //获取考试基础信息
    @PostMapping("/exam")
    public ResultVo getExamSubjectClass(@RequestBody ReportParamsVo params) {
        Integer examid = params.getExamid();
        N_Utils.validation(new Object[]{examid, "考试id", 1});
        Map map = eReportStudentService.getExamSubjectClass(examid);
        return new ResultVo(0, "获取成功", map);
    }

    //报告概况--成绩单
    @PostMapping("/rep")
    public ResultVo listStudentSubjectScoreByExamid(@RequestBody ReportParamsVo params) {
        Integer examid = params.getExamid();
        Integer studentid = params.getStudentid();
        N_Utils.validation(new Object[]{examid, "考试id", 1,studentid,"学生id",1});
        Map map = eReportStudentService.listStudentSubjectScoreByExamid(examid,studentid);
        return new ResultVo(0, "获取报告概况成绩单成功", map);
    }

    //报告概况--历史名次变化
    @PostMapping("/hr")
    public ResultVo listStudentRankHistory(@RequestBody ReportParamsVo params) {
        Integer studentid = params.getStudentid();
        N_Utils.validation(new Object[]{studentid,"学生id",1});
        List<Map> list = eReportStudentService.listStudentRankHistory(studentid);
        return new ResultVo(0, "获取报告概况历史名次成功", list);
    }

    //学科分析--学科排名和历史排名
    @PostMapping("/srank")
    public ResultVo getSubjectScoreByStudentid(@RequestBody ReportParamsVo params) {
        Integer studentid = params.getStudentid();
        Integer exmaid = params.getExamid();
        String subjectid = params.getSubjectid();
        N_Utils.validation(new Object[]{exmaid,"考试id",1,studentid,"学生id",1,subjectid,"科目id",3});
        Map map = eReportStudentService.getSubjectScoreByStudentid(exmaid,studentid,subjectid);
        return new ResultVo(0, "获取科目排名成功", map);
    }

    //学科分析--知识点分析
    @PostMapping("/spoint")
    public ResultVo listSubjectPoints(@RequestBody ReportParamsVo params) {
        Integer studentid = params.getStudentid();
        Integer exmaid = params.getExamid();
        String subjectid = params.getSubjectid();
        N_Utils.validation(new Object[]{exmaid,"考试id",1,studentid,"学生id",1,subjectid,"科目id",3});
        List<Map> map = eReportStudentService.listSubjectPoints(exmaid,studentid,subjectid);
        return new ResultVo(0, "获取科目知识点分析成功", map);
    }

    //学科分析--难易度分析
    @PostMapping("/scomp")
    public ResultVo listSubjectComplexitys(@RequestBody ReportParamsVo params) {
        Integer studentid = params.getStudentid();
        Integer exmaid = params.getExamid();
        String subjectid = params.getSubjectid();
        N_Utils.validation(new Object[]{exmaid,"考试id",1,studentid,"学生id",1,subjectid,"科目id",3});
        List<Map> map = eReportStudentService.listSubjectComplexitys(exmaid,studentid,subjectid);
        return new ResultVo(0, "获取科目难易度分析成功", map);
    }
    //学科分析--题型分析
    @PostMapping("/sqtype")
    public ResultVo listSubjectqtypes(@RequestBody ReportParamsVo params) {
        Integer studentid = params.getStudentid();
        Integer exmaid = params.getExamid();
        String subjectid = params.getSubjectid();
        N_Utils.validation(new Object[]{exmaid,"考试id",1,studentid,"学生id",1,subjectid,"科目id",3});
        List<Map> map = eReportStudentService.listSubjectQtypes(exmaid,studentid,subjectid);
        return new ResultVo(0, "获取科目题型分析成功", map);
    }
    //学科分析--试题分析
    @PostMapping("/sques")
    public ResultVo listSubjectQuestions(@RequestBody ReportParamsVo params) {
        Integer studentid = params.getStudentid();
        Integer exmaid = params.getExamid();
        String subjectid = params.getSubjectid();
        N_Utils.validation(new Object[]{exmaid,"考试id",1,studentid,"学生id",1,subjectid,"科目id",3});
        List<Map> map = eReportStudentService.listSubjectQuestions(exmaid,studentid,subjectid);
        return new ResultVo(0, "获取科目试题分析成功", map);
    }

    //试卷分析
    @PostMapping("/spaper")
    public ResultVo getStudentPaper(@RequestBody ReportParamsVo params) {
        Integer studentid = params.getStudentid();
        Integer exmaid = params.getExamid();
        String subjectid = params.getSubjectid();
        N_Utils.validation(new Object[]{exmaid,"考试id",1,studentid,"学生id",1,subjectid,"科目id",3});
        Map map = eReportStudentService.getStudentPaperQuestions(exmaid,studentid,subjectid);
        return new ResultVo(0, "获取科目试卷分析成功", map);
    }

    //错题集--科目错题数量
    @PostMapping("/serrornum")
    public ResultVo listStudentSubjectErrorQues(@RequestBody ReportParamsVo params) {
        Integer studentid = params.getStudentid();
        Integer exmaid = params.getExamid();
        N_Utils.validation(new Object[]{exmaid,"考试id",1,studentid,"学生id",1});
        List<Map> map = eReportStudentService.listStudentSubjectErrorQues(exmaid,studentid);
        return new ResultVo(0, "获取科目错题数量成功", map);
    }

    //学生报告-错题集-学生科目下错题（附件）
    @PostMapping("/serrorfj")
    public ResultVo listStudentErrorQuesForFj(@RequestBody ReportParamsVo params) {
        Integer studentid = params.getStudentid();
        Integer exmaid = params.getExamid();
        String subjectid = params.getSubjectid();
        N_Utils.validation(new Object[]{exmaid,"考试id",1,studentid,"学生id",1,subjectid,"科目id",3});
        List<Map> map = eReportStudentService.listStudentErrorQuestionsFj(exmaid,studentid,subjectid);
        return new ResultVo(0, "获取科目错题成功", map);
    }

    //学生报告-错题集-学生科目下错题（题库）
    @PostMapping("/serrorq")
    public ResultVo listStudentErrorQuesForTK(@RequestBody ReportParamsVo params) {
        Integer studentid = params.getStudentid();
        Integer exmaid = params.getExamid();
        String subjectid = params.getSubjectid();
        N_Utils.validation(new Object[]{exmaid,"考试id",1,studentid,"学生id",1,subjectid,"科目id",3});
        Map map = eReportStudentService.listStudentErrorQuestionsTk(exmaid,studentid,subjectid);
        return new ResultVo(0, "获取科目错题成功", map);
    }


    //获取考试基础--班级教师权限下班级
    @PostMapping("/examt")
    public ResultVo getExamSubjectClassForTeacher(@RequestBody ReportParamsVo params) {
        Integer examid = params.getExamid();
        N_Utils.validation(new Object[]{examid, "考试id", 1,params.getUserid(),"用户id",1});
        Map map = eReportStudentService.getExamSubjectClassForTeacher(examid,params.getUserid());
        return new ResultVo(0, "获取成功", map);
    }
}
