package com.lightinit.hsdatashow.controller.admin;

import com.lightinit.hsdatashow.model.admin.EducationOrganizationResultModel;
import com.lightinit.hsdatashow.model.admin.FacilitiesResultModel;
import com.lightinit.hsdatashow.service.admin.IFacilitiesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping(value = "/admin/facilities")
public class FacilitiesController {

    @Autowired
    private IFacilitiesService facilitiesService ;


    /**
     * 环卫设施
     * @return
     */
    @RequestMapping(value = "/sanitationIndex.htm")
    public ModelAndView sanitationIndex(){
        ModelAndView modelAndView = new ModelAndView("admin/facilities/sanitationIndex") ;
        return modelAndView ;
    }

    /**
     * 环卫设施
     * @return
     */
    @RequestMapping(value = "getSanitation.action")
    @ResponseBody
    public List<FacilitiesResultModel> getSanitation(String categoryName){
        return facilitiesService.getFacility(categoryName) ;
    }

    /**
     * 监控设施
     * @return
     */
    @RequestMapping(value = "/monitorIndex.htm")
    public ModelAndView monitorIndex(){
        ModelAndView modelAndView = new ModelAndView("admin/facilities/monitorIndex") ;
        return modelAndView ;
    }

    /**
     * 监控设施
     * @return
     */
    @RequestMapping(value = "getMonitor.action")
    @ResponseBody
    public List<EducationOrganizationResultModel> getMonitor(String categoryName, String name){
        return facilitiesService.getMonitor(categoryName,name) ;
    }

    /**
     * 公共设施
     * @return
     */
    @RequestMapping(value = "/publishIndex.htm")
    public ModelAndView publishIndex(){
        ModelAndView modelAndView = new ModelAndView("admin/facilities/publishIndex") ;
        return modelAndView ;
    }

    /**
     * 公共设施
     * @return
     */
    @RequestMapping(value = "getPublish.action")
    @ResponseBody
    public List<EducationOrganizationResultModel> getPublish(String categoryName, String name){
        return facilitiesService.getMonitor(categoryName,name) ;
    }
//    public ResultState getCommunal(){
//        return facilitiesService.getCommunal();
//
//    }


    /**
     * 路政设施
     * @return
     */
    @RequestMapping(value = "/readIndex.htm")
    public ModelAndView governmentIndex
    (){
        ModelAndView modelAndView = new ModelAndView("admin/facilities/readIndex") ;
        return modelAndView ;
    }

    /**
     * 路政设施
     * @return
     */
    @RequestMapping(value = "getRead.action")
    @ResponseBody
    public List<FacilitiesResultModel> getRead(String categoryName){
        return facilitiesService.getFacility(categoryName) ;
    }
}
