package com.xhkjedu.sapi.controller.region;

import com.xhkjedu.sapi.service.region.RegionAnalyzeService;
import com.xhkjedu.utils.N_Utils;
import com.xhkjedu.vo.ResultVo;
import com.xhkjedu.sapi.vo.region.CloudVo;
import com.xhkjedu.sapi.vo.region.RegionParam;
import com.xhkjedu.sapi.vo.region.WorkRtnVo;
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 RegionAnalyzeController
 * @description
 * @date 2021/5/13 15:08
 **/
@RestController
@RequestMapping("/ranalyze")
public class RegionAnalyzeController {
    @Resource
    private RegionAnalyzeService regionAnalyzeService;

    //获取区平台信息
    @PostMapping("/cloud")
    public ResultVo getCloudINfo(){
        CloudVo cloudVo = regionAnalyzeService.getCloudInfo();
        return new ResultVo(0,"获取区信息成功",cloudVo);
    }

    @PostMapping("/rqnum")
    public ResultVo getResourceQuestionNum(){
        Map map = regionAnalyzeService.getResourceQuestionNum();
        return new ResultVo(0,"获取资源、试题总量成功",map);
    }

    @PostMapping("/rtype")
    public ResultVo listResourceTypeNum(){
        Map map = regionAnalyzeService.listResourceTypeNum();
        return new ResultVo(0,"获取资源类型统计成功",map);
    }

    @PostMapping("/qsubject")
    public ResultVo listQuestionSubjectNum(){
        Map map = regionAnalyzeService.listQuestionSubjectNum();
        return new ResultVo(0,"获取试题科目统计成功",map);
    }

    @PostMapping("/slist")
    public ResultVo listSchool(@RequestBody RegionParam param){
        List<Map> list = regionAnalyzeService.listSchool(param);
        return new ResultVo(0,"获取学校列表成功",list);
    }

    @PostMapping("/ctslist")
    public ResultVo listClassTeacherStudentNum(@RequestBody RegionParam param){
        List<Map> list = regionAnalyzeService.listClassTeacherStudentNum(param);
        return new ResultVo(0,"获取学段班级、教师、学生总量成功",list);
    }


    //教学统计--作业提交率
    @PostMapping("/workc")
    public ResultVo listPaperCommitMonth(@RequestBody RegionParam param){
        N_Utils.validation(new Object[]{param.getBegintime(),"开始时间",1,param.getEndtime(),"结束时间",1});
        Map map = regionAnalyzeService.listPaperCommitMonth(param);
        return new ResultVo(0,"获取教学统计作业提交率成功",map);
    }
    //教学统计--各教学任务
    @PostMapping("/work")
    public ResultVo listGuideCommitMonth(@RequestBody RegionParam param){
        N_Utils.validation(new Object[]{param.getBegintime(),"开始时间",1,param.getEndtime(),"结束时间",1});
        List<WorkRtnVo> map = regionAnalyzeService.listWorkCommitMonth(param);
        return new ResultVo(0,"获取各教学任务统计信息成功",map);
    }

    //布置作业统计
    @PostMapping("/papernum")
    public ResultVo listPapernumMonth(@RequestBody RegionParam param){
        N_Utils.validation(new Object[]{param.getBegintime(),"开始时间",1,param.getEndtime(),"结束时间",1});
        Map map = regionAnalyzeService.listPapernumMonth(param);
        return new ResultVo(0,"获取布置作业次数成功",map);
    }

    //课堂使用统计--使用次数
    @PostMapping("/roomnum")
    public ResultVo listRoomNumMonth(@RequestBody RegionParam param){
        N_Utils.validation(new Object[]{param.getBegintime(),"开始时间",1,param.getEndtime(),"结束时间",1});
        Map map = regionAnalyzeService.listRoomNumMonth(param);
        return new ResultVo(0,"获取课堂使用数量成功",map);
    }

    //课堂使用统计--互动次数
    @PostMapping("/roomask")
    public ResultVo listRoomAskNumMonth(@RequestBody RegionParam param){
        N_Utils.validation(new Object[]{param.getBegintime(),"开始时间",1,param.getEndtime(),"结束时间",1});
        List<Map> map = regionAnalyzeService.listRoomAskNumMonth2(param);
        return new ResultVo(0,"获取课堂互动数量成功",map);
    }

}
