package com.xhkjedu.sapi.controller.region;

import com.xhkjedu.sapi.service.region.RegionResourceService;
import com.xhkjedu.utils.N_Utils;
import com.xhkjedu.vo.ResultVo;
import com.xhkjedu.sapi.vo.region.RLevelVo;
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 RegionResourceController
 * Description TODO 可视化--资源统计界面
 * Author WN
 * Date 2021/5/27 18:01
 **/
@RestController
@RequestMapping("rr")
public class RegionResourceController {
    @Resource
    RegionResourceService regionResourceService;

    //资源统计
    @PostMapping("/res")
    public ResultVo listResourceNum(){
        Map map = regionResourceService.listResourcesAnalyze();
        return new ResultVo(0,"获取资源统计成功",map);
    }

    //试题统计
    @PostMapping("/que")
    public ResultVo listQuestionNum(){
        Map map = regionResourceService.listQuestionSubjectnum();
        return new ResultVo(0,"获取试题统计成功",map);
    }

    //校本资源统计
    @PostMapping("/ress")
    public ResultVo listResourceSchoolNum(){
        List<RLevelVo> levels = regionResourceService.listResourceSchool();
        return new ResultVo(0,"获取校本统计成功",levels);
    }

    //资源统计--热门统计
    @PostMapping("/resh")
    public ResultVo listResourceHot(){
        List<Map> lst = regionResourceService.listResourceHot();
        return new ResultVo(0,"获取热门资源成功",lst);
    }

    //资源统计--校本贡献值
    @PostMapping("/resg")
    public ResultVo listResourceForSchool(@RequestBody RegionParam regionParam){
        Integer begintime = regionParam.getBegintime();
        Integer endtime = regionParam.getEndtime();
        N_Utils.validation(new Object[]{begintime,"开始时间",1,endtime,"结束时间",1});
        Map map = regionResourceService.listResourceForSchool(begintime,endtime);
        return new ResultVo(0,"获取资源校本贡献成功",map);
    }

    //资源统计--校本贡献值
    @PostMapping("/queg")
    public ResultVo listQuestionForSchool(@RequestBody RegionParam regionParam){
        Integer begintime = regionParam.getBegintime();
        Integer endtime = regionParam.getEndtime();
        N_Utils.validation(new Object[]{begintime,"开始时间",1,endtime,"结束时间",1});
        Map map = regionResourceService.listQuestionForSchool(begintime,endtime);
        return new ResultVo(0,"获取试题校本贡献成功",map);
    }


}
