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 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;

/**
 * @Author: sunxiang
 * @Date: 2018/8/14 15:01
 * @Description:
 **/
@Controller
@RequestMapping(value = "/admin/cockpit")
public class CockpitController {

    @Autowired
    private ICockpitService cockpitService;
    @RequestMapping(value = "index.htm")
    public ModelAndView index(){
        ModelAndView modelAndView = new ModelAndView("admin/cockpit/index");
        return modelAndView;
    }

    @RequestMapping(value = "index.action")
    @ResponseBody
    public ResultState getIndex(){
        ArrayList<String> findIndexes = new ArrayList<>();
        for(String s: DicCategoryIndex.getInstacne().getDicMap().keySet()){
            if(DicCategoryIndex.RESIDENTSERVICEINDEX.equals(s)||DicCategoryIndex.SOCIETYSECURITYINDEX.equals(s)){
                continue;
            }
            findIndexes.add(s);
        }
        return cockpitService.getIndex(findIndexes);
    }
}
