package com.yida.data.school.exam.controller;

import com.yida.data.common.core.common.ResultBean;
import com.yida.data.school.dto.exam.ClassCompareDTO;
import com.yida.data.school.dto.exam.ScoreSectionStasticDTO;
import com.yida.data.school.exam.service.CoreExaminationAnalysisService;
import com.yida.data.school.vo.exam.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "成绩-后台-分析")
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/exam/analysis")
public class CoreExaminationAnalysisController {
    private final CoreExaminationAnalysisService coreExaminationAnalysisService;

    @ApiOperation("班级对比表")
    @PostMapping("/classCompare")
    public ResultBean<List<ExamScoreAnalysisVO>> classCompare(@RequestBody ClassCompareDTO dto) {
        return ResultBean.buildSuccess(coreExaminationAnalysisService.classCompare(dto));
    }

    @ApiOperation("分数段统计")
    @PostMapping("/scoreSectionStastic")
    public ResultBean<List<ScoreSectionStasticVO>> scoreSectionStastic(@RequestBody ScoreSectionStasticDTO dto) {
        return ResultBean.buildSuccess(coreExaminationAnalysisService.scoreSectionStasticDTO(dto));
    }

    @ApiOperation("成绩分布表")
    @GetMapping("/scoreDistribute")
    public ResultBean<ScoreDistributeVO> scoreDistribute(@ApiParam("考试id") Long examId,
                                                         @ApiParam("学生id") Long studentId,
                                                         @ApiParam("课程id") Long courseId) {
        return ResultBean.buildSuccess(coreExaminationAnalysisService.scoreDistribute(examId, studentId, courseId));
    }

    @ApiOperation("成绩趋势")
    @GetMapping("/scoreTrend")
    public ResultBean<List<ScoreTrendVO>> scoreTrend(@ApiParam("考试id") Long examId,
                                                     @ApiParam("学生id") Long studentId,
                                                     @ApiParam("课程id") Long courseId) {
        return ResultBean.buildSuccess(coreExaminationAnalysisService.scoreTrend(examId, studentId, courseId));
    }

    @ApiOperation("成绩与平均成绩对比")
    @GetMapping("/scoreAndAvgCompare")
    public ResultBean<List<ScoreAndAvgCompareVO>> scoreAndAvgCompare(@ApiParam("考试id") Long examId,
                                                                     @ApiParam("学生id") Long studentId) {
        return ResultBean.buildSuccess(coreExaminationAnalysisService.scoreAndAvgCompare(examId, studentId));
    }
}

