package com.srs.web.controller.stureg;

import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.comprehensive.domain.Vo.DataScreen;
import com.srs.stureg.service.ISrsStuRegCountService;
import com.srs.stureg.service.ISrsStuRegService;
import com.srs.system.service.ISysPostService;
import com.srs.web.controller.common.RoleBool;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Api
@RestController
@RequestMapping("/system/regcount")
public class SrsRegCountController extends BaseController {

    @Autowired
    private ISrsStuRegCountService srsStuRegCountService;

    @Autowired
    ISysPostService _postService;


    @ApiOperation("统计各学院")
    @GetMapping("/countDept")
    public AjaxResult countDept(){
        boolean hasRole = RoleBool.isHigh(getUserId(),_postService);
        if(hasRole){
            List<Map<String,Object>> list = srsStuRegCountService.countDept();
            return AjaxResult.success(list);
        }else{
            return AjaxResult.error(401,"你无权做这些");
        }
    }
    @ApiOperation("统计各班级")
    @GetMapping("/countCLass")
    public AjaxResult countCLass(){
        boolean hasRole = RoleBool.isHigh(getUserId(),_postService);
        if(hasRole){
            List<Map<String,Object>> list = srsStuRegCountService.countClass();
            return AjaxResult.success(list);
        }else{
            return AjaxResult.error(401,"你无权做这些");
        }
    }

    @ApiOperation("统计各时间段")
    @GetMapping("/countHour")
    public AjaxResult countHour(){
        boolean hasRole = RoleBool.isHigh(getUserId(),_postService);
        if(hasRole){
            List<Map<String,Object>> list = srsStuRegCountService.countHour();
            return AjaxResult.success(list);
        }else{
            return AjaxResult.error(401,"你无权做这些");
        }
    }

    @ApiOperation("统计生源地")
    @GetMapping("/countArea")
    public AjaxResult countArea(){
        boolean hasRole = RoleBool.isHigh(getUserId(),_postService);
        if(hasRole){
            List<DataScreen> list = srsStuRegCountService.countArea();
            return AjaxResult.success(list);
        }else{
            return AjaxResult.error(401,"你无权做这些");
        }
    }

    @ApiOperation("统计前十专业报道")
    @GetMapping("/countMajorTop10")
    public AjaxResult countMajorTop10(){
        boolean hasRole = RoleBool.isHigh(getUserId(),_postService);
        if(hasRole){
            List<Map<String,Object>> list = srsStuRegCountService.countMajorTop10();
            return AjaxResult.success(list);
        }else{
            return AjaxResult.error(401,"你无权做这些");
        }
    }

    @ApiOperation("统计已报道")
    @GetMapping("/countNowAt")
    public AjaxResult countNowAt(){
        boolean hasRole = RoleBool.isHigh(getUserId(),_postService);
        if(hasRole){
            Map<String,Object> list = srsStuRegCountService.countNowAt();
            return AjaxResult.success(list);
        }else{
            return AjaxResult.error(401,"你无权做这些");
        }
    }

    @ApiOperation("统计性别")
    @GetMapping("/countGender")
    public AjaxResult countGender(){
        boolean hasRole = RoleBool.isHigh(getUserId(),_postService);
        if(hasRole){
            List<DataScreen> list = srsStuRegCountService.countGender();
            return AjaxResult.success(list);
        }else{
            return AjaxResult.error(401,"你无权做这些");
        }
    }

    @GetMapping("/count")
    public AjaxResult count(){
        boolean hasRole = RoleBool.isHigh(getUserId(),_postService);
        if(hasRole){
            return AjaxResult.success(srsStuRegCountService.selectCountByRegStatus());
        }else{
            return AjaxResult.error(401,"你无权做这些");
        }
    }

    /**
     * 统计到站情况
     */
    @ApiOperation("统计到站情况")
    @GetMapping("/atstation")
    public AjaxResult atStationCount(){

        return AjaxResult.success(srsStuRegCountService.atStationCount());
    }

    /**
     * 统计到站情况,分长岗校区和里建
     */
    @ApiOperation("统计到站情况")
    @GetMapping("/atStationByCampus")
    public AjaxResult atStationByCampusCount(){

        return AjaxResult.success(srsStuRegCountService.atStationByCampusCount());
    }

}
