package com.xhkjedu.smarking.controller.exam;

import com.xhkjedu.smarking.model.exam.MsClassStudent;
import com.xhkjedu.smarking.service.exam.MsSubjectSearchService;
import com.xhkjedu.smarking.vo.exam.EBaseVo;
import com.xhkjedu.smarking.vo.exam.ESubjectVo;
import com.xhkjedu.utils.N_Utils;
import com.xhkjedu.vo.ResultVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Description 查找设置
 * @Author YWX
 * @Date 2024/10/18 17:46
 **/
@RestController
@RequestMapping("/msearch")
public class MsSubjectSearchController {
    @Resource
    private MsSubjectSearchService subjectSearchService;

    /**
     * 查找设置
     *
     * @return com.xhkjedu.vo.ResultVo
     * @Param [base]
     * @Author ywx
     * @Date 2022/7/19 9:01
     **/
    @PostMapping("/list_st")
    public ResultVo listSearchTeacher(@RequestBody EBaseVo base) {
        Integer schoolid = base.getSchoolid();
        N_Utils.validation(new Object[]{schoolid, "学校id", 1});
        List<Map> list = subjectSearchService.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 EBaseVo subject) {
        String username = subject.getUsername();
        Integer examid = subject.getExamid();
        N_Utils.validation(new Object[]{username, "姓名", 2, examid, "考试id", 1});
        Map list = subjectSearchService.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 ESubjectVo subject) {
        String subjectid = subject.getSubjectid();
        Integer examid = subject.getExamid();
        N_Utils.validation(new Object[]{subjectid, "科目id", 2, examid, "考试id", 1});
        List<Map<String,Object>> list = subjectSearchService.listClassTeacher(examid, subjectid);
        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 MsClassStudent student) {
        Integer examid = student.getExamid();
        String examno = student.getExamno();
        String subjectid = student.getSubjectid();
        N_Utils.validation(new Object[]{examid, "考试id", 1, examno, "考号", 2, subjectid, "科目id", 2});
        List<Map> list = subjectSearchService.listStudentByExamno(examid, examno, subjectid);
        return new ResultVo(0, "获取成功", list);
    }
}
