/**
 * <p>Copyright:Copyright(c) 2017</p>
 * <p>Company:上海中信信息发展股份有限公司</p>
 * <p>包名:com.cesgroup.cesmonitor.web</p>
 * <p>文件名:ReportCommonController.java</p>
 * <p>创建时间:2017年5月24日 上午10:46:28</p>
 * <p>作者:user</p>
 */

package com.cesgroup.cesmonitor.web;

import java.util.List;

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

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 com.cesgroup.cesmonitor.service.ReportCommonService;
import com.zabbix4j.host.HostObject;
import com.zabbix4j.hostgroup.HostgroupObject;

/**
 *
 * @author sl
 * @version 1.0.0 2017年5月24日
 */
@Controller
@RequestMapping("report")
public class ReportCommonController {

    @Autowired
    private ReportCommonService reportCommonService;

    /**
     *
     * @return 所有主机组
     */
    @RequestMapping(value = "selectAllHostGroups")
    @ResponseBody
    public List<HostgroupObject> selectAllHostGroups() {
        return reportCommonService.selectAllHostGroupsService();
    }

    /**
     * 用于页面中主机组选择了"所有主机组"
     *
     * @return 所有主机
     */
    @RequestMapping(value = "selectAllHosts")
    @ResponseBody
    public List<HostObject> selectAllHosts() {
        return reportCommonService.selectAllHostsService();
    }

    /**
     *
     * @param group
     *            主机组名称
     * @return 特点主机组所属的所有主机
     */
    @RequestMapping(value = "selectHostByHostGroupName")
    @ResponseBody
    public List<HostObject> selectHostByHostGroupName(String group) {
        return reportCommonService.selectHostByHostGroupNameService(group);
    }

    /**
     * 下载文件
     *
     * @param request
     *            请求
     * @param response
     *            响应
     */
    @RequestMapping(value = "download")
    public void download(String filename, HttpServletRequest request, HttpServletResponse response) {
        reportCommonService.download(filename, request, response);
    }
    
    /**
     * 下载文件
     *
     * @param request
     *            请求
     * @param response
     *            响应
     */
    @RequestMapping(value = "gettimeslot")
    public List<String> gettimeslot(Integer interval) {

        return reportCommonService.gettimeslot(interval);
        
    }
}
