package com.cesgroup.cesmonitor.web;

import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cesgroup.cesmonitor.bean.FastGroup;
import com.cesgroup.cesmonitor.bean.FastGroupGraph;
import com.cesgroup.cesmonitor.service.QuickAccessGraphService;
import com.zabbix4j.ZabbixApiException;
import com.zabbix4j.graph.GraphObject;
import com.zabbix4j.hostgroup.HostgroupGetResponse;
import com.zabbix4j.hostgroup.HostgroupGetResponse.Result;

/**
 * 上海中信信息发展股份有限公司;
 * 创建时间:2018年1月22日;
 * @author luxiao
 * 这里是快速访问的控制层，调用业务层代码，会与前台进行数据的交互，包括返回的JSON，HTML代码;
 */
@Controller
@RequestMapping("/quickaccessgraph")
public class QuickAccessGraphController {

    @Autowired
    private QuickAccessGraphService QuickAccessGraphService;

    /*
    *
    * @return 返回快速访问组
    */
   @RequestMapping(value = "findFastGroupByUser")
   @ResponseBody
   public List<FastGroup> findFastGroupByUser(String userId) {
	   List<FastGroup> fastGroupList = null;
	try {
		fastGroupList = QuickAccessGraphService.findFastGroupByUser(userId);
	} catch (Exception e) {
		e.printStackTrace();
	}
       return fastGroupList;
   }

   /*
   *
   * @return 返回图形组
   */
  @RequestMapping(value = "findFastGroupGraphByFastGroupId")
  @ResponseBody
  public List<FastGroupGraph> findFastGroupGraphByFastGroupId(String fastGroupId) {
      return QuickAccessGraphService.findFastGroupGraphByFastGroupId(fastGroupId);
  }
  
  /*
  *
  * @return 返回图形
  */
 @RequestMapping(value = "getGraphByGraphId")
 @ResponseBody
 public List<GraphObject> getGraphByGraphId(Integer graphId) throws ZabbixApiException {
     return QuickAccessGraphService.getGraphByGraphId(graphId);
 }


}