package com.qmth.jkserver.controller.system;

import com.qmth.jkserver.params.ExamRoomMonitorInfoParams;
import com.qmth.jkserver.service.ExamRoomMonitorInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author by xf
 * @date 2019/4/1.
 */
@RestController
@RequestMapping("/system/examRoomMonitor")
public class ExamRoomMonitorInfoController {

    @Resource
    @Lazy
    private ExamRoomMonitorInfoService examRoomMonitorInfoService;

    /**
     * 根据所有正在进行中的考试
     * @return
     */
    @RequestMapping(value = "/getExamInProgress", method = RequestMethod.POST)
    public Object getExamInProgress(){
        return examRoomMonitorInfoService.getExamInProgress();
    }


    /**
     * 根据planId查询所有省份
     * @param examCode
     * @return
     */
    @RequestMapping(value = "/getProvinceByExamCode", method = RequestMethod.POST)
    public Object getProvinceByExamCode(@RequestParam("examCode") String examCode){
        return examRoomMonitorInfoService.getProvinceByExamCode(examCode);
    }

    /**
     * 根据province查询所有市
     * @param province
     * @return
     */
    @RequestMapping(value = "/getCityByProvince", method = RequestMethod.POST)
    public Object getCityByProvince(@RequestParam("province") String province){
        return examRoomMonitorInfoService.getCityByProvince(province);
    }

    /**
     * 获取所有的考点根据省+市+考试识别码
     * @param request
     * @param response
     * @param examCode
     * @param province
     * @param city
     * @return
     */
    @RequestMapping(value ="/getPlaceByProvinceAndCityAndExamCode",method = RequestMethod.POST)
    public Object getPlaceByProvinceAndCityAndExamCode(HttpServletRequest request, HttpServletResponse response,
                                                       @RequestParam(value="examCode",required=true) String examCode,
                                                       @RequestParam(value="province",required=false) String province,
                                                       @RequestParam(value="city",required=false) String city){
        return examRoomMonitorInfoService.getPlaceByProvinceAndCityAndExamCode(province, city, examCode);
    }

    /**
     * 查询列表
     * @param examRoomMonitorInfoParams
     * @param curPage
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "/pageQuery", method = RequestMethod.POST)
    public Object pageQuery(ExamRoomMonitorInfoParams examRoomMonitorInfoParams, int curPage, int pageSize){
        return examRoomMonitorInfoService.pageQuery(examRoomMonitorInfoParams, curPage, pageSize);
    }

    /**
     * 查询报名人数、应考考次、连接数、登录数
     * @param params
     * @return
     */
    @RequestMapping(value = "/queryCountInfo", method = RequestMethod.POST)
    public Object queryCountInfo(ExamRoomMonitorInfoParams params){
        return examRoomMonitorInfoService.queryCountInfo(params);
    }

    /**
     * 查询报考类型
     * @param examCode
     * @return
     */
    @RequestMapping(value = "/queryCategoryPercent", method = RequestMethod.POST)
    public Object queryCategoryPercent(@RequestParam("examCode") String examCode){
        return examRoomMonitorInfoService.queryCategoryPercent(examCode);
    }

    /**
     * 全国考点统计情况
     * @param examCode
     * @return
     */
    @RequestMapping(value = "/queryPlacePercent", method = RequestMethod.POST)
    public Object queryPlacePercent(@RequestParam("examCode") String examCode){
        return examRoomMonitorInfoService.queryPlacePercent(examCode);
    }
}
