package com.lightinit.hsdatashow.controller.admin;

import com.lightinit.hsdatashow.dictionary.DicCategoryIndex;
import com.lightinit.hsdatashow.model.ResultState;
import com.lightinit.hsdatashow.service.admin.ICockpitService;
import com.lightinit.hsdatashow.service.admin.IHomeService;
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.ArrayList;

/**
 * 用户管理
 */
@Controller("adminHomeController")
@RequestMapping(value = {"/admin", "/admin/home"})
public class HomeController {

    @Autowired
    private IHomeService homeService;
    @Autowired
    private ICockpitService cockpitService;
    @RequestMapping(value = {"/", "/index.action"})
    public ModelAndView index(){
        ModelAndView modelAndView = new ModelAndView("admin/home/index");
        return modelAndView;
    }

    /*
     *@Description   城市绿化
     *@Param
     *@Date 2018/8/15
     *@return
     **/
    @RequestMapping(value="moreindex.action")
    @ResponseBody
    public ResultState getMoreIndex(){
        ArrayList<String> findIndexes = new ArrayList<>();
        findIndexes.add(DicCategoryIndex.SOCIETYDEVELOPINDEX);
        findIndexes.add(DicCategoryIndex.ECOLOGICALENVIRONMENTINDEX);
        findIndexes.add(DicCategoryIndex.RESIDENTSERVICEINDEX);
        findIndexes.add(DicCategoryIndex.SOCIETYSECURITYINDEX);
        return cockpitService.getIndex(findIndexes);
    }

    /*
     *@Description   城市绿化
     *@Param
     *@Date 2018/8/15
     *@return
     **/
    @RequestMapping(value="citygreening.action")
    @ResponseBody
    public ResultState getCityGreening(){
        return homeService.getCityGreening();
    }

    /*
     *@Description   社会安全
     *@Param
     *@Date 2018/8/15
     *@return
     **/
    @RequestMapping(value="societysecurity.action")
    @ResponseBody
    public ResultState getSocietySecurity(){
        return homeService.getSocietySecurity();
    }

    /*
    *@Description   污染指数
    *@Param
    *@Date 2018/8/16
    *@return
    **/
    @RequestMapping(value="pollutionindex.action")
    @ResponseBody
    public ResultState getPollutionIndex(){
        return homeService.getPollutionIndex();
    }

    /*
    *@Description   社会发展
    *@Param
    *@Date 2018/8/15
    *@return
    **/
    @RequestMapping(value="societydevelop.action")
    @ResponseBody
    public ResultState getSocietyDevelop(){
        return homeService.getSocietyDevelop();
    }
}
