package com.xhkjedu.smarking.controller.exam;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xhkjedu.smarking.model.exam.MsClassStudent;
import com.xhkjedu.smarking.model.exam.MsExam;
import com.xhkjedu.smarking.service.exam.SubjectScoreService;
import com.xhkjedu.smarking.vo.exam.SCStudentVo;
import com.xhkjedu.utils.N_Utils;
import com.xhkjedu.utils.PageUtil;
import com.xhkjedu.vo.PageResult;
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;

/**
 * @Description 阅卷考试表相关操作
 * @Author auto
 * @Date 2024-10-15
 */
@RestController
@RequestMapping("/sscore")
public class SubjectScoreController {
    @Resource
    private SubjectScoreService subjectScoreService;
    /*
     * @Description 成绩管理-科目成绩列表
     * @Date 2024/11/11 15:25:52
     * @Author WN
     * @Param [msExam]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/list")
    public ResultVo listExamSubjectScore(@RequestBody MsExam msExam) {
        Integer examid = msExam.getExamid();
        N_Utils.validation(new Object[]{examid, "考试id", 1});
        return new ResultVo(0, "获取成功", subjectScoreService.listExamSubjectScore(examid));
    }

    /*
     * @Description 成绩管理-缺考学生
     * @Date 2024/11/11 15:56:13
     * @Author WN
     * @Param [cvo]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/miss")
    public ResultVo listExamSubjectMiss(@RequestBody MsClassStudent cvo) {
        Integer page = cvo.getPage();
        Integer size = cvo.getPageSize();
        N_Utils.validation(new Object[]{cvo.getExamid(), "考试id", 1,cvo.getSubjectid(), "科目id", 2,page, "显示页码", 1, size, "显示条数", 1});

        PageHelper.startPage(page, size);
        List<Map<String, Object>> list = subjectScoreService.listExamSubjectScoreByClass(cvo);
        PageResult pageResult = PageUtil.getPageResult(new PageInfo<>(list));
        return new ResultVo(0, "获取成功", pageResult);
    }

    /*
     * @Description 成绩管理-缺考学生-导出
     * @Date 2024/11/11 15:56:13
     * @Author WN
     * @Param [cvo]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/miss_export")
    public ResultVo listExamSubjectMissExport(@RequestBody SCStudentVo cvo) {
        N_Utils.validation(new Object[]{cvo.getExamid(), "考试id", 1});
        if(!N_Utils.isListNotEmpty(cvo.getSubjectids())){
            return new ResultVo(1, "请选择科目");
        }
        return new ResultVo(0, "获取成功", subjectScoreService.listSubjectMissStudentExport(cvo));
    }
}
