package com.xhkjedu.sexam.controller.exam;

import com.xhkjedu.sexam.model.exam.EBase;
import com.xhkjedu.sexam.model.exam.EClassStudent;
import com.xhkjedu.sexam.model.exam.ESubject;
import com.xhkjedu.sexam.service.exam.ESubjectSearchService;
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 ESubjectSearchController
 * @description 查找设置
 * @date 2022/7/20 9:36
 **/
@RestController
@RequestMapping("/es")
public class ESubjectSearchController {
    @Resource
    private ESubjectSearchService eSubjectSearchService;

    /**
     * 查找设置
     *
     * @return com.xhkjedu.vo.ResultVo
     * @Param [base]
     * @Author ywx
     * @Date 2022/7/19 9:01
     **/
    @PostMapping("/list_st")
    public ResultVo listSearchTeacher(@RequestBody EBase base) {
        Integer schoolid = base.getSchoolid();
        N_Utils.validation(new Object[]{schoolid, "学校id", 1});
        List<Map> list = eSubjectSearchService.listSearchTeacher(schoolid);
        return new ResultVo(0, "获取成功", list);
    }

    /**
     * 快捷设置
     *
     * @return com.xhkjedu.vo.ResultVo
     * @Param [subject]
     * @Author ywx
     * @Date 2022/7/19 14:33
     **/
    @PostMapping("/list_qt")
    public ResultVo listQuickTeacher(@RequestBody EBase subject) {
        String username = subject.getCreatename();
        Integer examid = subject.getExamid();
        N_Utils.validation(new Object[]{username, "姓名", 2, examid, "考试id", 1});
        Map list = eSubjectSearchService.listQuickTeacher(username, examid);
        return new ResultVo(0, "获取成功", list);
    }

    /**
     * 按班设置
     *
     * @return com.xhkjedu.vo.ResultVo
     * @Param [subject]
     * @Author ywx
     * @Date 2022/7/19 16:56
     **/
    @PostMapping("/list_ct")
    public ResultVo listClassTeacher(@RequestBody ESubject subject) {
        String subjectid = subject.getSubjectid();
        Integer examid = subject.getExamid();
        N_Utils.validation(new Object[]{subjectid, "科目id", 2, examid, "考试id", 1});
        List<Map> list = eSubjectSearchService.listClassTeacher(examid, subjectid);
        return new ResultVo(0, "获取成功", list);
    }

    /**
     * 考试科目阅卷设置列表
     *
     * @return com.xhkjedu.vo.ResultVo
     * @Param [base]
     * @Author ywx
     * @Date 2022/7/21 16:59
     **/
    @PostMapping("/list_subject")
    public ResultVo listSubject(@RequestBody EBase base) {
        Integer examid = base.getExamid();
        N_Utils.validation(new Object[]{examid, "考试id", 1});
        Map map = eSubjectSearchService.listSubject(examid);
        return new ResultVo(0, "获取成功", map);
    }

    /**
     * 主监考人查找
     *
     * @return com.xhkjedu.vo.ResultVo
     * @Param [base]
     * @Author ywx
     * @Date 2022/7/29 14:32
     **/
    @PostMapping("/list_zt")
    public ResultVo listMasterTeacher(@RequestBody EBase base) {
        Integer schoolid = base.getSchoolid();
        N_Utils.validation(new Object[]{schoolid, "学校id", 1});
        List<Map> list = eSubjectSearchService.listMasterTeacher(schoolid);
        return new ResultVo(0, "获取成功", list);
    }

    /**
     * 主监考人快捷查找
     *
     * @return com.xhkjedu.vo.ResultVo
     * @Param [base]
     * @Author ywx
     * @Date 2022/7/29 15:25
     **/
    @PostMapping("/list_qzt")
    public ResultVo listQuickMasterTeacher(@RequestBody EBase base) {
        Integer schoolid = base.getSchoolid();
        String username = base.getCreatename();
        N_Utils.validation(new Object[]{schoolid, "学校id", 1, username, "姓名", 2});
        Map list = eSubjectSearchService.listQuickMasterTeacher(schoolid, username);
        return new ResultVo(0, "获取成功", list);
    }

    /**
     * @Description 按考试搜索考试学生
     * @Param [student]
     * @Return com.xhkjedu.vo.ResultVo
     * @Author wn
     * @Date 2022/8/26 10:13
     **/
    @PostMapping("/stu")
    public ResultVo listStudentByExamno(@RequestBody EClassStudent student) {
        Integer examid = student.getExamid();
        String examno = student.getExamno();
        N_Utils.validation(new Object[]{examid, "考试id", 1, examno, "考号", 2});
        List<Map> list = eSubjectSearchService.listStudentByExamno(examid, examno);
        return new ResultVo(0, "获取成功", list);
    }
}
