package com.cmos.msgframe.admin.action;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cmos.msgframe.admin.service.IConnectionService;
import com.cmos.msgframe.common.util.OutPutParameter;

/**
 * 项目名称：cmos-msg-admin 类名称：ConnectionAction 类描述： 客户端连接管理控制层 创建人：guozq5
 * 创建时间：2016-11-11 上午10:32:38 修改人：guozq5 修改时间：2016-11-11 上午10:32:38 修改备注：
 * 
 * @version
 * 
 */
@Controller
@RequestMapping("/connection")
public class ConnectionController {

	@Resource
	private IConnectionService connectionService;

	/**
	 * @Title: getConConnectionList
	 * @Description: 查询消费者客户端端的连接信息
	 * @param @param consumerGroup
	 * @param @param topic
	 * @param @return
	 * @param @throws Exception
	 * @return List<Map<String,String>> 返回类型
	 * @throws
	 */
	@RequestMapping(value = "/conList", method = RequestMethod.POST)
	@ResponseBody
	public OutPutParameter getConConnectionList(HttpServletRequest request) throws Exception {
		int start = Integer.parseInt(request.getParameter("start"));		
		int end = Integer.parseInt(request.getParameter("limit"));
		String topic = request.getParameter("topic");
		String consumerGroup = request.getParameter("consumerGroup");
		return connectionService.getConConnectionList(consumerGroup, topic,start,end+start);
	}

	/**
	 * @Title: getProConnectionList
	 * @Description: 查询消生产者客户端端的连接信息
	 * @param @param producerGroup
	 * @param @param topic
	 * @param @return
	 * @param @throws Exception
	 * @return List<Map<String,String>> 返回类型
	 * @throws
	 */
	@RequestMapping(value = "/proList", method = RequestMethod.POST)
	@ResponseBody
	public OutPutParameter getProConnectionList(HttpServletRequest request) throws Exception {
		String topic = request.getParameter("topic");
		String producerGroup = request.getParameter("producerGroup");
		return connectionService.getProConnectionList(producerGroup, topic);
	}

	/**
	 * @Title: getConConnectiondetail
	 * @Description: 查询单个消费者的详细信息
	 * @param @param consumerGroup
	 * @param @param topic
	 * @param @return
	 * @param @throws Exception
	 * @return List<Map<String,String>> 返回类型
	 * @throws
	 */
	@RequestMapping(value = "/detail", method = RequestMethod.POST)
	@ResponseBody
	public OutPutParameter getConConnectiondetail(HttpServletRequest request) throws Exception {
		String topic = request.getParameter("topic");
		int start = Integer.parseInt(request.getParameter("start"));		
		int end = Integer.parseInt(request.getParameter("limit"));
		String consumerGroup = request.getParameter("consumerGroup");
		return connectionService.getConConnectiondetail(consumerGroup, topic,start,start+end);
	}
}
