package com.xhkjedu.sapi.controller.region;

import com.xhkjedu.sapi.service.region.RPaperAnalyzeService;
import com.xhkjedu.utils.N_Utils;
import com.xhkjedu.vo.ResultVo;
import com.xhkjedu.sapi.vo.region.RegionParam;
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;

/**
 * @ClassName RPaperAnalyzeController
 * Description TODO 作业统计
 * Author WN
 * Date 2021/7/13 16:14
 **/
@RestController
@RequestMapping("rpa")
public class RPaperAnalyzeController {
    @Resource
    RPaperAnalyzeService rPaperAnalyzeService;

    //作业试题统计
    @PostMapping("/pnum")
    public ResultVo getResourceQuestionNum(@RequestBody RegionParam param){
        Integer level = param.getLevel();
        N_Utils.validation(new Object[]{level,"学段",1,param.getYear(),"学年",1});
        Map map = rPaperAnalyzeService.getRegionPaperNum(param);
        return new ResultVo(0,"获取作业数量统计成功",map);
    }

    //作业率统计--作业
    @PostMapping("/ratep")
    public ResultVo listRegionSchoolRatePaper(@RequestBody RegionParam param){
        Integer level = param.getLevel();
        N_Utils.validation(new Object[]{level,"学段",1,param.getYear(),"学年",1});
        Map map = rPaperAnalyzeService.listRegionSchoolRatePaper(param);
        return new ResultVo(0,"获取作业率统计成功",map);
    }

    //作业率统计--背诵
    @PostMapping("/rater")
    public ResultVo listRegionSchoolRateRecite(@RequestBody RegionParam param){
        Integer level = param.getLevel();
        N_Utils.validation(new Object[]{level,"学段",1,param.getYear(),"学年",1});
        Map map = rPaperAnalyzeService.listRegionSchoolRateRecite(param);
        return new ResultVo(0,"获取背诵率统计成功",map);
    }

    //作业率统计--预习率
    @PostMapping("/ratepre")
    public ResultVo getRegionSchoolRatePreview(@RequestBody RegionParam param){
        Integer level = param.getLevel();
        N_Utils.validation(new Object[]{level,"学段",1,param.getYear(),"学年",1});
        Map map = rPaperAnalyzeService.getRegionSchoolRatePreview(param);
        return new ResultVo(0,"获取预习率统计成功",map);
    }

    //人均作业用时
    @PostMapping("/avgp")
    public ResultVo listRegionSchoolUsetimePaper(@RequestBody RegionParam param){
        Integer level = param.getLevel();
        N_Utils.validation(new Object[]{level,"学段",1,param.getYear(),"学年",1});
        List<Map> lst= rPaperAnalyzeService.listRegionSchoolUsetimePaper(param);
        return new ResultVo(0,"获取人均作业用时成功",lst);
    }
    //人均预习用时
    @PostMapping("/avgpre")
    public ResultVo listRegionSchoolUsetimePreview(@RequestBody RegionParam param){
        Integer level = param.getLevel();
        N_Utils.validation(new Object[]{level,"学段",1,param.getYear(),"学年",1});
        List<Map> lst= rPaperAnalyzeService.listRegionSchoolUsetimePreview(param);
        return new ResultVo(0,"获取人均预习用时成功",lst);
    }

}
