package com.xhkjedu.sapi.controller.region;

import com.xhkjedu.sapi.service.region.SResourceService;
import com.xhkjedu.utils.N_Utils;
import com.xhkjedu.vo.ResultVo;
import com.xhkjedu.sapi.vo.region.RegionParam;
import org.springframework.beans.factory.annotation.Autowired;
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 java.util.List;
import java.util.Map;

/**
 * @ClassName SResourceController
 * Description TODO 校园可视化--资源统计
 * Author WN
 * Date 2021/6/24 11:01
 **/
@RestController
@RequestMapping("sr")
public class SResourceController {
    @Autowired
    private SResourceService sResourceService;

    //资源统计
    @PostMapping("/res")
    public ResultVo listResourceNum(@RequestBody RegionParam regionParam){
        int schoolid = regionParam.getSchoolid();
        N_Utils.validation(new Object[]{schoolid,"学校id",1});
        Map map = sResourceService.listSchoolResourcesAnalyze(schoolid);
        return new ResultVo(0,"获取学校资源统计成功",map);
    }

    //试题统计
    @PostMapping("/que")
    public ResultVo listQuestionNum(@RequestBody RegionParam regionParam){
        int schoolid = regionParam.getSchoolid();
        N_Utils.validation(new Object[]{schoolid,"学校id",1});
        Map map = sResourceService.listSchoolQuestionAnalyze(schoolid);
        return new ResultVo(0,"获取学校试题统计成功",map);
    }

    //校本资源统计
    @PostMapping("/xbres")
    public ResultVo listResourceSchool(@RequestBody RegionParam regionParam){
        int schoolid = regionParam.getSchoolid();
        N_Utils.validation(new Object[]{schoolid,"学校id",1});
        Map map = sResourceService.listSchoolResourceSchool(schoolid);
        return new ResultVo(0,"获取校本资源统计成功",map);
    }

    //热门资源统计
    @PostMapping("/hotres")
    public ResultVo listResourceHot(@RequestBody RegionParam regionParam){
        int schoolid = regionParam.getSchoolid();
        N_Utils.validation(new Object[]{schoolid,"学校id",1});
        List<Map> lst = sResourceService.listSchoolResourceHot(schoolid);
        return new ResultVo(0,"获取热门资源统计成功",lst);
    }

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

}
