package com.xhkjedu.sstudy.controller.paperstudent;

import com.xhkjedu.sstudy.model.paperreport.PaperRstudent;
import com.xhkjedu.sstudy.model.paperstudent.TPaperClass;
import com.xhkjedu.sstudy.service.paperreport.PaperStudentReportService;
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 PaperStudentReportController
 * @description 学生作业报告
 * @date 2023/6/8 14:52
 **/
@RestController
@RequestMapping("/psr")
public class PaperStudentReportController {
    @Resource
    private PaperStudentReportService paperStudentReportService;

    /**
     * @Description 作业概况
     * @Param [paper]
     * @Author ywx
     * @Date 2023/6/8 16:13
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("po")
    public ResultVo getPaperOverview(@RequestBody PaperRstudent paper) {
        Integer paperid = paper.getPaperid();
        Integer classid = paper.getClassid();
        Integer studentid = paper.getStudentid();
        N_Utils.validation(new Object[]{paperid, "作业id", 1, classid, "班级id", 1, studentid, "学生id", 1});
        Map map = paperStudentReportService.getPaperOverview(paperid, classid, studentid);
        return new ResultVo(0, "获取作业概况成功", map);
    }

    /**
     * @Description 作业详情
     * @Param [paper]
     * @Author ywx
     * @Date 2023/6/8 16:19
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("pd")
    public ResultVo getPaperDetail(@RequestBody PaperRstudent paper) {
        Integer paperid = paper.getPaperid();
        Integer classid = paper.getClassid();
        Integer studentid = paper.getStudentid();
        N_Utils.validation(new Object[]{paperid, "作业id", 1, classid, "班级id", 1, studentid, "学生id", 1});
        Map map = paperStudentReportService.getPaperDetail(paperid, classid, studentid);
        return new ResultVo(0, "获取作业详情成功", map);
    }

    /**
     * @Description 优秀作答
     * @Param [paper]
     * @Author ywx
     * @Date 2023/6/9 10:51
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("ga")
    public ResultVo listGoodAnswer(@RequestBody TPaperClass paper) {
        Integer paperid = paper.getPaperid();
        Integer classid = paper.getClassid();
        Integer papertype = paper.getPapertype();
        N_Utils.validation(new Object[]{paperid, "作业id", 1, classid, "班级id", 1, papertype, "作业类型", 1});
        List<Map> list = paperStudentReportService.listGoodAnswer(paperid, classid, papertype);
        return new ResultVo(0, "获取优秀作答成功", list);
    }

    /**
     * @Description 作业基本信息
     * @Param [paper]
     * @Author ywx
     * @Date 2023/6/9 16:26
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("p")
    public ResultVo getPaper(@RequestBody PaperRstudent paper) {
        Integer paperid = paper.getPaperid();
        Integer classid = paper.getClassid();
        Integer studentid = paper.getStudentid();
        N_Utils.validation(new Object[]{paperid, "作业id", 1, classid, "班级id", 1, studentid, "学生id", 1});
        Map map = paperStudentReportService.getPaper(paperid, classid, studentid);
        return new ResultVo(0, "获取作业基本信息成功", map);
    }
}
