package com.xhkjedu.smarking.controller.exam;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xhkjedu.smarking.model.exam.MsSubjectBadstudent;
import com.xhkjedu.smarking.model.exam.MsSubjectInvigilate;
import com.xhkjedu.smarking.service.exam.MsSubjectBadstudentService;
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("/msbad")
public class MsSubjectBadstudentController {
    @Resource
    private MsSubjectBadstudentService msSubjectBadstudentService;

    /*
     * @Description 学生-保存违规记录
     * @Date 2024/11/13 17:12:27
     * @Author WN
     * @Param [badstudent]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/save")
    public ResultVo save(@RequestBody MsSubjectBadstudent badstudent) {
        N_Utils.validation(new Object[]{badstudent.getStudentid(), "学生id", 1, badstudent.getMsid(), "考试科目id", 1
                , badstudent.getBadtype(), "违规类型", 1,badstudent.getMpid(),"试卷id",1});
        msSubjectBadstudentService.add(badstudent);
        return new ResultVo(0, "保存成功");
    }


    /*
     * @Description 实时监控--监控班级
     * @Date 2024/11/13 17:45:23
     * @Author WN
     * @Param [invigilate]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/jk_class")
    public ResultVo listJkSchoolClass(@RequestBody MsSubjectInvigilate invigilate) {
        Integer teacherid = invigilate.getTeacherid();
        Integer msid = invigilate.getMsid();
        N_Utils.validation(new Object[]{teacherid, "教师id", 1, msid, "考试科目id", 1});
        Map map = msSubjectBadstudentService.listJkSchoolClass(invigilate);
        return new ResultVo(0, "获取成功", map);
    }

    /*
     * @Description 实时监控-班级学生
     * @Date 2024/11/13 17:59:01
     * @Author WN
     * @Param [invigilate]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/jk_stu")
    public ResultVo listJkClassStudents(@RequestBody MsSubjectInvigilate invigilate) {
        Integer msid = invigilate.getMsid();
        Integer classid = invigilate.getClassid();
        N_Utils.validation(new Object[]{msid, "考试科目id", 1, classid, "班级id", 1});
        List<Map<String, Object>> list = msSubjectBadstudentService.listClassStus(invigilate);
        return new ResultVo(0, "获取成功", list);
    }

    /*
     * @Description 实时监控-学生进场、提交情况
     * @Date 2024/11/14 9:39:31
     * @Author WN
     * @Param [invigilate]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/jk_inrate")
    public ResultVo getSubjectStuInRate(@RequestBody MsSubjectInvigilate invigilate) {
        Integer msid = invigilate.getMsid();
        N_Utils.validation(new Object[]{msid, "考试科目id", 1});
        Map<String, Object> map = msSubjectBadstudentService.getSubjectStuInRate(invigilate);
        return new ResultVo(0, "获取成功", map);
    }

    /*
     * @Description 实时监控-学生违规照片
     * @Date 2024/11/14 9:56:47
     * @Author WN
     * @Param [invigilate]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/jk_badstu")
    public ResultVo listSubjectStuBadPics(@RequestBody MsSubjectInvigilate invigilate) {
        Integer msid = invigilate.getMsid();
        Integer page = invigilate.getPage();
        Integer pageSize = invigilate.getPageSize();
        N_Utils.validation(new Object[]{msid, "考试科目id", 1, page, "页码", 1, pageSize, "显示条数", 1});
        PageHelper.startPage(page, pageSize);
        List<Map<String, Object>> list = msSubjectBadstudentService.listSubjectStuBadPics(invigilate);
        PageResult pageResult = PageUtil.getPageResult(new PageInfo<>(list));
        return new ResultVo(0, "获取成功", pageResult);
    }
}
