package com.lightinit.hsdatashow.controller.admin;

import com.lightinit.hsdatashow.model.ResultState;
import com.lightinit.hsdatashow.model.admin.EducationOrganizationResultModel;
import com.lightinit.hsdatashow.service.admin.ITrafficMonitorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @Author: sunxiang
 * @Date: 2018/12/9 13:20
 * @Description:
 **/
@Controller
@RequestMapping(value = "/admin/trafficmonitor")
public class TrafficMonitorController {

    @Autowired
    private ITrafficMonitorService trafficMonitorService;
    @RequestMapping(value = "/index.htm")
    public ModelAndView index(){
        ModelAndView modelAndView = new ModelAndView("admin/trafficmonitor/index") ;
        return modelAndView ;
    }

    @RequestMapping(value = "trafficcondition.action/{type}")
    @ResponseBody
    public ResultState getTrafficCondition(@PathVariable String type){
        if(StringUtils.isEmpty(type)){
            return null;
        }
        String chinaType=null;
        if("gjc".equals(type)){
            chinaType="公交车";
        }else if("czc".equals(type)){
            chinaType="出租车";
        }else if("zxc".equals(type)){
            chinaType="自行车";
        }
        return trafficMonitorService.getTrafficCondition(chinaType);
    }

    @RequestMapping(value = "getTrafficmonitor.action")
    @ResponseBody
    public List<EducationOrganizationResultModel> getTrafficmonitor(String categoryName,String name){
        return trafficMonitorService.getEducationOrganization(categoryName,name) ;
    }


}
